[Python-Dev] range objects in 3.x
"Martin v. Löwis"
martin at v.loewis.de
Sat Sep 24 00:01:07 CEST 2011
> Yes, I realize this is because range returned a list in 2.x. However,
> aren't __contains__, __getitem__, count, and index implemented in 3.x
> range because 2.x range returned lists?
No, they are implemented because they are meaningful, and with an
obvious meaning. "Is 30 in the range from 10 to 40?" is something
that everybody will answer the same way. "What is the fifth element
of the range from 10 to 40?" may not have such a universal meaning,
but people familiar with the mathematical concept of an interval
can readily guess the answer (except that they may wonder whether
to start counting at 0 or 1).
"Is the range from 5 to 100 larger than the range from 10 to 100?"
is something that most people would answer as "yes" (I believe),
yet
py> range(5,100) > range(10,100)
False
Regards,
Martin
More information about the Python-Dev
mailing list