[Python-Dev] pprint(iterator) (original) (raw)
Guido van Rossum guido at python.org
Tue Jan 27 23:14:13 CET 2009
- Previous message: [Python-Dev] pprint(iterator)
- Next message: [Python-Dev] pprint(iterator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jan 27, 2009 at 2:06 PM, Oleg Broytmann <phd at phd.pp.ru> wrote:
On Tue, Jan 27, 2009 at 01:46:35PM -0800, Raymond Hettinger wrote:
<enumerate object: 'A', 'B', 'C', 'D', 'E', 'F'> I like the idea, and I prefer this formatting. Also bear in mind there are infinite generators, and there are iterators that cannot be reset. For infinite generators pprint() must have a parameter, say, 'maxitems', and print <generator: 'A', 'B', 'C', 'D', 'E', 'F', ...>. The situation with iterators that cannot be reset should be documented.
This pretty much kills the proposal. Calling a "print" function like pprint() should not have a side effect on the object being printed. I'd be okay of pprint() special-cased the views returned by e.g. dict.keys(), but if all we know is that the argument has a next method, pprint() should not be calling that.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] pprint(iterator)
- Next message: [Python-Dev] pprint(iterator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]