On 2011-09-17, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Fri, Sep 16, 2011 at 8:19 PM, Grant Edwards <invalid@invalid.invalid> > wrote: >>> Here's another one-liner using a generator instead of map: >>> >>> ? ? ?sum(int(c) for c in str(2**1000)) >> >> Just in case you can't spare the 3KB required for the list of integers >> that map creates. :) >> >> In this case it doesn't matter, but it's not hard to find problems >> where the difference between the memory requirements for a generator >> and a map/list-comprehension are significant enough to worry about. > > Unless otherwise specified, I generally assume that code on this list > is for Python 3, and map in Python 3 returns an iterator.
Indeed, I forgot about that (I'm still using Python 2 since I use some libraries that haven't been ported). -- Grant -- http://mail.python.org/mailman/listinfo/python-list