Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread spir
On Wed, 03 Mar 2010 15:41:34 -0500 Dave Angel da...@ieee.org wrote: John wrote: Hi, I just read a few pages of tutorial on list comprehenion and generator expression. From what I gather the difference is [ ] and ( ) at the ends, better memory usage and the something the tutorial

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread Andreas Kostyrka
Am Mittwoch, 3. März 2010 21:41:34 schrieb Dave Angel: John wrote: Hi, I just read a few pages of tutorial on list comprehenion and generator expression. From what I gather the difference is [ ] and ( ) at the ends, better memory usage and the something the tutorial labeled as lazy

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread Steven D'Aprano
On Fri, 5 Mar 2010 07:57:18 am Andreas Kostyrka wrote: A list comprehension builds a whole list at one time. So if the list needed is large enough in size, it'll never finish, and besides, you'll run out of memory and crash. A generator expression builds a function instead which *acts*

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-04 Thread spir
On Thu, 4 Mar 2010 21:57:18 +0100 Andreas Kostyrka andr...@kostyrka.org wrote: I would rather write it: x_it = iter(x) # get an iterator for x try: while True: i = x_it.next() print i except StopIteration: pass x_it = iter(x) # get an iterator for x while True:

[Tutor] lazy? vs not lazy? and yielding

2010-03-03 Thread John
Hi, I just read a few pages of tutorial on list comprehenion and generator expression. From what I gather the difference is [ ] and ( ) at the ends, better memory usage and the something the tutorial labeled as lazy evaluation. So a generator 'yields'. But what is it yielding too? John

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-03 Thread Dave Angel
John wrote: Hi, I just read a few pages of tutorial on list comprehenion and generator expression. From what I gather the difference is [ ] and ( ) at the ends, better memory usage and the something the tutorial labeled as lazy evaluation. So a generator 'yields'. But what is it yielding