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

Nick Coghlan ncoghlan at gmail.com
Thu Jan 29 22:54:35 CET 2009


Michael Foord wrote:

Don't we have a pretty-print API - and isn't it spelled str ?

For the "reiterable" cases like dictionary views (where the object is not consumed), an appropriate str or repr should be written).

Whether that is something as simple as ".items()" for an items view, or something more complicated that more directly shows the content of the view, I'm not sure.

For the standard iterators like enumerate and ranged, I would suggest that they be modified to use a repr of the form:

"reversed()" "enumerate()" "iter()" "iter(, )"

While those obviously won't show how much of the iterable has been consumed, neither do the current representations.

Cheers, Nick.

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



More information about the Python-Dev mailing list