Calling a generator multiple times
Greg Ewing
greg at cosc.canterbury.ac.nz
Mon Dec 10 00:53:57 EST 2001
Steven Majewski wrote:
>
> And when you use these generators in a for loop, they two bits of
> confusion seem to cancel each other out.
That's a nice way of putting it! Well said.
> "for i in g(10):" really
> behaves just like it's definition. I'm guessing that this fact
> was one of the selling points for this syntax -- that if you didn't
> look under the hood and just USED them, they would not be confusing.
Unfortunately, when you *do* come to look under the
hood, there's twice as much confusion as there would
have been if the confusion had been spread around
more evenly.
So, looked at that way, Guido has chosen to put all
the confusion in one spot rather than distributing
it. :-)
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list