Proposed new PEP: print to expand generators

Mel Wilson mwilson-to at sympatico.ca
Sun Jun 4 11:42:04 EDT 2006


Terry Reedy wrote:
> "James J. Besemer" <jb at cascade-sys.com> wrote in message 
> news:4482390E.7060809 at cascade-sys.com...
>> 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.
> Iterating over an iterator is usually destructive.  So you would be 
> printing what it was but no longer is.  This is why iterators are printed 
> differently from sequences.

I guess the motivation is the case of people who would set 
up an iterator specifically to print from it.

print-as-debug-aid would get badly broken by the proposal, 
and I'd find that painful.

         Mel.



More information about the Python-list mailing list