[0..9] list (range) syntax

Wildemar Wildenburger lasses_weil at klapptsowieso.net
Wed Oct 24 19:16:57 EDT 2007


Michal Bozon wrote:
> many Python newcomers are confused why
> range(10), does not include 10.
> 
It produces a list of ten elements. Also the documentation is quite 
clear on the topic. And lastly: This will probably really bother you for 
a week, then no more.


> If there was a proposal for the new
> syntax for ranges, which is known
> e.g. from Pascal or Ruby...
> 
>>>> [0..10]
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> 
> ...is there a chance to be approved ?
> 
Quite close to none. It is too much cosmetics and too little 
enhancement. What would that make possible that is impossible by now or 
what would that make easier that is really hard?

And if you really need something like that, write a function:

def fullrange(start, end):
     r = range(start, end)
     r.append(end)
     return r

/W



More information about the Python-list mailing list