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

Raymond:
> I'm in agreement with the comments that the proposed __str__ revision is 
> confusing.

In what way is it "confusing"?

I'm especially perplexed that Julien apparently thinks it is confusing when 
emitted by str(), but educational and useful when emitted by repr(). This makes 
no sense to me.

I think Julien's idea is a good one, just not for repr, and I don't think it is 
confusing at all.


Raymond:
> most other iterators can't show a preview of the output without actually 
> consuming some of their inputs

`range` is not some arbitrary iterator, in fact it isn't an iterator at all:

py> r = range(10)
py> iter(r) is r
False


It is a sequence, like list and tuple, and like list and tuple it is perfectly 
capable of showing its content (in full or part) on demand. Other important 
built-in sequence types like strings, lists and tuples aren't hamstrung with 
the restriction not to do anything iterators can't do, there's no good reason 
for range objects to be given that restriction.


Julien:
> I'm closing this.

Not so hasty, please. Some of us think this is a worthwhile enhancement. You 
might have changed your mind, but the idea is bigger than you now :-)

I'm taking this discussion to Python-Ideas to see if there is community 
interest in this feature. If so, I'm going to reopen the issue.

----------

_______________________________________
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