On the bug tracker, there is a proposal to enhance range objects so that 
printing them will display a snapshot of the values included, including 
the end points. For example:

print(range(10))

currently displays "range(10)". The proposal is for the __str__ method 
to instead return "<range object [0, 1, ..., 8, 9]>".

https://bugs.python.org/issue35200

print(range(2, 200, 3)) would display

<range object [2, 5, ..., 194, 197]>

Note that the original proposal was for range objects' __repr__ to 
display this behaviour. But given the loss of eval(repr(obj)) round 
tripping, and the risk of breaking backwards compatibility, it was 
decided that isn't acceptable but using the same display for __str__ 
(and hence produced by print) would be nearly as useful but without the 
downsides.

The developer who proposed the feature, Julien, now wants to reject the 
feature request. I think it is still a useful feature for range objects. 
What do others think? Is this worth re-opening?



-- 
Steve
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to