Calling a generator multiple times
oren-py-l at hishome.net
Sat Dec 8 13:42:18 CET 2001
On Sat, Dec 08, 2001 at 12:50:42PM +0100, Just van Rossum wrote:
> Oren Tirosh wrote:
> > On Sat, Dec 08, 2001 at 12:30:25AM +0000, Courageous wrote:
> > >
> > > >A generator is a function or method that -- by virtue of using the yield
> > > >statement --
> > >
> > > I understand how it works, intuitively. My objection is not that
> > > I don't understand it, but rather that a lone keyword appearing
> > > in the content of the method definition actually changes what is
> > > being defined. That's just plain wrong.
> > I agree. It should be immediately apparent that a generator function is
> > not a regular instance of the 'function' type. [ ... ]
> "That's just plain wrong"
> "It should be immediately apparent that..."
> If it _was_ "plain wrong" it wouldn't be the way it is. I mentioned the
> archives of python-iterators list before, but I think the PEP is a better
Ok. it's not 'plain wrong'. It's merely 'slightly confusing'.
I fully agree with this particular BDFL pronouncement. Based on the
alternatives presented in PEP 255 the best one has been chosen.
I think that the alternative I have presented might have been preferred,
though, if it were included in the proposals at that time.
More information about the Python-list