Generator expressions v/s list comprehensions
Martin DeMello
martindemello at yahoo.com
Mon Aug 30 09:16:06 EDT 2004
Peter Hansen <peter at engcorp.com> wrote:
> A small correction:
>
> Martin DeMello wrote:
>
> > Here's a simple example
> >
> > linecount = sum(1 for line in file)
> > linecount = sum([1 for line in file])
> >
> > The former requires an in-memory list equal to the size of the file.
> ^^^^^^
> I think you meant "the latter"...
Oops - I did indeed.
martin
More information about the Python-list
mailing list