[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Include
rangeobject.h,2.16,2.17
Greg Ball
gball@cfa.harvard.edu
Mon, 9 Jul 2001 10:50:16 -0400 (EDT)
> but I don't see a problem with that. I also left out the 'contains'
> implementation.
> Still-not-understanding-*why*-<wink>-ly y'rs,
In the fine tradition of xrange, that 'contains' implementation is
slightly broken. It doesn't have proper object equality semantics.
Python 2.1 (#1, Jul 4 2001, 14:48:37)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> r, xr = range(10), xrange(10)
>>> 1.1 in r
0
>>> 1.1 in xr
1
>>> 1+0j in r
1
>>> 1+0j in xr
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: can't convert complex to int; use e.g. int(abs(z))
--Greg Ball