[Python-Dev] Xrange and Slices
Oren Tirosh
oren-py-d@hishome.net
Thu, 27 Jun 2002 03:00:53 -0400
On Thu, Jun 27, 2002 at 12:44:36AM -0400, Tim Peters wrote:
> > >>> xrange(1,100,2)
> > xrange(1, 101, 2)
> >
> > It's been there since at least Python 2.0. Hasn't anyone noticed this
> > bug before?
>
> It's been that way since xrange() was introduced, but nobody *called* it a
> bug before. The two expressions are equivalent:
>
> >>> list(xrange(1, 100, 2)) == list(xrange(1, 101, 2))
> True
I found that seconds after hitting 'y'...
> [Greg Ewing]
> > ...
> > So... why *isn't* slice == <type 'slice'>?
>
> It is in current CVS Python, but still range != <type 'range'>, and won't
> until someone cares enough to change it.
There is no spoo^H^H^H^H <type 'range'>.
xrange is <type 'xrange'> and range is <built-in function range>.
Oren