[Python-Dev] Re: Re: anonymous blocks

Terry Reedy tjreedy at udel.edu
Mon Apr 25 16:38:49 CEST 2005


"Nick Coghlan" <ncoghlan at gmail.com> wrote in message 
news:426CB7C2.8030508 at gmail.com...
> Guido van Rossum wrote:
> > statement expansion", I think we can expect EXPR to produce a value
> > that is already an iterator (rather than merely an interable).
>
> Not supporting iterables makes it harder to write a class which is 
> inherently usable in a with block, though. The natural way to make 
> iterable classes is to use 'yield' in the definition of __iter__ - if 
> iter() is not called, then that trick can't be used.

Would not calling iter() (or .__iter__) explicitly, instead of depending on 
the implicit call of for loops, suffice to produce the needed iterator?

tjr





More information about the Python-Dev mailing list