Range Operation pre-PEP

Greg Ewing see at my.signature
Wed May 9 07:06:56 CEST 2001


If you want to get this considered, you'll have to
make sure your PEP explicitly addresses all the reasons
for the rejection of PEP 204. (That might not be easy,
since the rejection notice attached to PEP 204 is
rather sketchy!)

One thing that comes to mind is the interpretation
of the endpoint. The syntax strongly suggests that the
endpoint is inclusive, as you propose. But this is
not the most useful meaning in Python. Most of the
time, range() is used in constructs such as

  for i in range(len(mylist)):

which would become

  for i in 0..len(mylist)-1:

The need to include the -1 is a nuisance and
potential source of error.

The alternative, making the endpoint exclusive,
would make the meaning of the .. construct
somewhat unintuitive.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list