[Python-Dev] pprint(iterator) (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Tue Jan 27 23:14:37 CET 2009


Raymond Hettinger wrote:

<enumerate object: 'A', 'B', 'C', 'D', 'E', 'F'>

I quite like the idea of something along those lines. For example:

try: itr = iter(obj) except TypeError: pass else: return "<iterable %s: %s>" % (obj.class.name, ))

Doing this only in pprint also reduces the chances of accidentally consuming an iterator (which was a reasonable objection when I suggested changing the str implementation on some of the standard iterators some time ago).

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list