[Python-Dev] string representation of range in 3.0

Steve Holden steve at holdenweb.com
Wed Apr 16 15:58:39 CEST 2008

Isaac Morland wrote:
> On Wed, 16 Apr 2008, Paul Moore wrote:
>> On 16/04/2008, Armin Rigo <arigo at tunes.org> wrote:
>>> What about the less confusing and more readily generalizable:
>>>   <range object 0, 1, ..., 9>
>>> It would also be helpful IMHO to use this kind of repr for most built-in
>>> iterators and iterables, instead of their mosty-useless default repr.
>> I quite like this. But as a non-beginner, I'll freely admit that my
>> intuitions are suspect :-)
> I like this too.  For iterators, though, would you always show the next 
> couple of elements?  The values "contained in" the iterator will change as 
> the iterator iterates.  Alternatively, the representation could be 
> "frozen" to reflect the values originally pending in the iterator, but 
> then the representation wouldn't show anything about the current state of 
> the iterator.
If you consume values from the iterator to display them in the repr() 
where do you then propose to store them until the application wants 
them, and how do you distinguish between "real" and "repr" consumption 
of the values? "The next couple of elements" is a dangerous thing to use 
unless you don't mind them disappearing. And the last one's right out - 
you;d end up storing lists anyway!

Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

More information about the Python-Dev mailing list