[Python-Dev] range objects in 3.x

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Sep 24 01:25:11 CEST 2011


Ethan Furman wrote:

> The only reason I'm aware of at the moment is to prevent loss of 
> functionality from 2.x range to 3.x range.

Since 2.x range(...) is equivalent to 3.x list(range(...)), I don't
see any loss of functionality there.

Comparing range objects directly in 3.x is like comparing xrange
objects in 2.x, and there the comparison was arbitrary -- it
did *not* compare them like their corresponding lists:

Python 2.7 (r27:82500, Oct 15 2010, 21:14:33)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> a = xrange(5)
 >>> b = xrange(5)
 >>> a > b
True

-- 
Greg


More information about the Python-Dev mailing list