[Python-Dev] range objects in 3.x (original) (raw)

Benjamin Peterson benjamin at python.org
Fri Sep 23 20:14:36 CEST 2011


2011/9/23 Ethan Furman <ethan at stoneleaf.us>:

A question came up on StackOverflow about range objects and floating point numbers.  I thought about writing an frange that did for floats what range does for ints, so started examining the range class.  I noticed it has le, lt, eq, ne, ge, and gt methods.  Some experiments show that xrange in 2.x does indeed implement those operations, but in 3.x range does not (TypeError: unorderable types: range() > range()).

Was this intentional, or should I file a bug report?  (I was unable to find anything in the What's New documents; also, I did not test in 3.0, just in 2.7, 3.1, 3.2.)

That's simply a consequence of everything having comparisons defined in 2.x. The comparison is essentially meaningless.

-- Regards, Benjamin



More information about the Python-Dev mailing list