[Python-Dev] pprint(iterator) (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Tue Jan 27 23:14:37 CET 2009
- Previous message: [Python-Dev] pprint(iterator)
- Next message: [Python-Dev] pprint(iterator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] pprint(iterator)
- Next message: [Python-Dev] pprint(iterator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]