[Python-Dev] _length_cue()

Armin Rigo arigo at tunes.org
Fri Feb 10 14:33:08 CET 2006


Hi Nick,

On Fri, Feb 10, 2006 at 11:21:52PM +1000, Nick Coghlan wrote:
> Do they really need anything more sophisticated than:
> 
>    def __repr__(self):
>      return "%s(%r)" % (type(self).__name__, self._subiter)
> 
> (modulo changes in the format of arguments, naturally. This simple one would 
> work for things like enumerate and reversed, though)

My goal here is not primarily to help debugging, but to help playing
around at the interactive command-line.  Python's command-line should
not be dismissed as "useless for real programmers"; I definitely use it
all the time to try things out.  It would be nicer if all these
iterators I'm not familiar with would give me a hint about what they
actually return, instead of:

>>> itertools.count(17)
count(17)                  # yes, thank you, not very helpful
>>> enumerate("spam")
enumerate("spam")          # with your proposed extension -- not better

However, if this kind of goal is considered "not serious enough" for
adding a private special method, then I'm fine with trying out a fishing
approach.


A bientot,

Armin.


More information about the Python-Dev mailing list