Message330065
On Sun, Nov 18, 2018 at 09:43:02PM +0000, 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 adequate first thought:
<range object [1, 2, ..., 8, 9]>
is explicit about what kind of object we have. Remember, there will be
times where people don't know they have a range object, and are printing
it to find out what they have.
Let's just move that from __repr__ to __str__.
> 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 empty range gets [] instead of nothing.
Certainly not. That looks like a list containing 1, 2, ellipsis, 8, 9,
and will only increase confusion about the difference between lists and
range objects. |
|
Date |
User |
Action |
Args |
2018-11-18 21:57:08 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger, ncoghlan, serhiy.storchaka, mdk, seluj78 |
2018-11-18 21:57:08 | steven.daprano | link | issue35200 messages |
2018-11-18 21:57:07 | steven.daprano | create | |
|