Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

With the proposed design, any two empty range objects have the same repr:

repr(range(0)) == repr(range(2, 2)) == repr(range(1, 5, -1)) etc.

Between this loss of information, and the loss of round-tripping through eval, 
I'm against this proposal. But I'd perhaps be in favour of it as the __str__ 
rather than __repr__, so that printing a range object displays in the proposed 
format.

By the way, the ``dumb_range_repr`` function in the PR could be simplified:

# untested
def dumb_range_repr(r):
    if len(r) < 5:
        return f"<range object {list(r)}>"
    else:
        return f"<range object [{r[0]}, {r[1]}, ..., {r[-2]}, {r[-1]}]>"

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35200>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to