Proposed new PEP: print to expand generators

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sun Jun 4 22:33:48 EDT 2006


James J. Besemer a écrit :
> 
(snip)
> 
> PEP -- EXTEND PRINT TO EXPAND GENERATORS
> 
> NUTSHELL
> 
> I propose that we extend the semantics of "print" such that if the 
> object to be printed is a generator then print would iterate over the 
> resulting sequence of sub-objects and recursively print each of the 
> items in order.
> 

Please, don't:

from itertools import cycle
def mygen():
     return cycle('this is a very bad idea'.split())





More information about the Python-list mailing list