[Python-Dev] More imformative iterator representations

Paul Prescod paul at prescod.net
Thu Apr 8 01:01:56 EDT 2004


Raymond Hettinger wrote:
>...
> An alternative to the read-eval-print approach is providing a custom
> __repr__() method for the builtin iterators.  The good news is that this
> approach is very clean. 

And worth doing!

A few questions:

  * will it be easy for end-users to write iterators that can repr 
nicely? Do you anticipate a base class or helper function to help?

  * might it make sense for enumerate to report something like:

<enumerate object <reversed(['h', 'g', 'f', ...])> ...>

If the underlying object's repr is helpful then enumerate at least might 
not discard the information.

  Paul Prescod




More information about the Python-Dev mailing list