A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-January/085551.html below:

[Python-Dev] pprint(iterator)

[Python-Dev] pprint(iterator) [Python-Dev] pprint(iterator)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__,
                                <as for list contents>))

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4