Stupid ways to spell simple code
Roy Smith
roy at panix.com
Sun Jun 30 13:44:15 EDT 2013
In article <51d06cb6$0$29999$c3e8da3$5496439d at news.astraweb.com>,
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> On Sun, 30 Jun 2013 16:06:35 +1000, Chris Angelico wrote:
>
> > So, here's a challenge: Come up with something really simple, and write
> > an insanely complicated - yet perfectly valid - way to achieve the same
> > thing. Bonus points for horribly abusing Python's clean syntax in the
> > process.
>
> Here's a trivially stupid way to find the length of an iterable:
>
> sum(1 for obj in iterable)
That's how you would do it in a map-reduce environment :-)
More information about the Python-list
mailing list