[issue35200] Make the half-open range behaviour easier to teach

2018-11-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: As a teacher, I think the proposal makes us worst off. It is far easier and more useful at the interactive prompt to use list() rather than print() to show ranges: >>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(range(2, 10))

[issue35200] Make the half-open range behaviour easier to teach

2018-11-19 Thread Steven D'Aprano
Steven D'Aprano 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

[issue35200] Make the half-open range behaviour easier to teach

2018-11-19 Thread Julien Palard
Julien Palard added the comment: Hi Raymond, I agree, there exist other means of teaching half closed range, but I was more concerned by self-taught students, alone facing the current range repr than students well accompanied. I also agree, let's not change the current repr (for backward

[issue35200] Make the half-open range behaviour easier to teach

2018-11-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: After more thought, I'm in agreement with the comments that the proposed __str__ revision is confusing. After teaching another Python intro course last week, I'm now thinking that no change should be made. There are other effective ways to teach

[issue35200] Make the half-open range behaviour easier to teach

2018-11-19 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Nov 18, 2018 at 10:27:11PM +, Julien Palard wrote: > > Julien Palard added the comment: > > If I understand correctly, you'd like str(range(10)) to return " [1, 2, ..., 8, 9]>"? Exactly the same as you suggested for repr(range(10)) to return,

[issue35200] Make the half-open range behaviour easier to teach

2018-11-18 Thread Julien Palard
Julien Palard added the comment: If I understand correctly, you'd like str(range(10)) to return ""? I'm really unconfortable doing this, for me __str__ is here to return an “informal or nicely printable string representation of an object", not a convoluted "<{type(object)} object ...>"

[issue35200] Make the half-open range behaviour easier to teach

2018-11-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Nov 18, 2018 at 09:43:02PM +, Julien Palard wrote: > My first though went to giving something really simple like: > > >>> print(range(10)) > 1, 2, ..., 8, 9 -1 Surely that would be your *second* thought, since you already had a perfectly

[issue35200] Make the half-open range behaviour easier to teach

2018-11-18 Thread Julien Palard
Julien Palard added the comment: My first though went to giving something really simple like: >>> print(range(10)) 1, 2, ..., 8, 9 But for the empty range it would give an empty string. It may make sense, but may also be surprising. The other way would be to print [1, 2, ..., 8. 9], so the

[issue35200] Make the half-open range behaviour easier to teach

2018-11-18 Thread Julien Palard
Julien Palard added the comment: In one hand I'm OK to enhance the __str__ of range, so I'll change my PR for this. It will not fix the issue, but let's not break backward compatibility. -- ___ Python tracker

[issue35200] Make the half-open range behaviour easier to teach

2018-11-18 Thread Nick Coghlan
Nick Coghlan added the comment: (Retitled the issue to better reflect the underlying feature request) As Steven describes, there are enough problems with changing range.__repr__ that if that's the proposal, then the only possible answer is "No", and closing the issue. However, changing