[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Include rangeobject.h,2.16,2.17

Thomas Wouters thomas@xs4all.net
Mon, 9 Jul 2001 14:31:04 +0200


On Sat, Jul 07, 2001 at 02:14:31PM -0400, Guido van Rossum wrote:

> I hear clearly that you want the advanced xrange() behavior to
> generate a warning before I take it out.  I still think that's
> unnecessary, given that nobody in their right mind uses it.  But since
> people who are out of their mind have access to lawyers too, you can
> go ahead and restore the old code and stuff it with warnings.  Make
> sure to add a warning for every feature that I've taken out!

Done:

>>> (xrange(9)[8:7]*6 == xrange(5) or xrange(4).start or xrange(3)).tolist() 
__main__:1: DeprecationWarning: xrange object slicing is deprecated; convert to list instead
__main__:1: DeprecationWarning: xrange object multiplication is deprecated; convert to list instead
__main__:1: DeprecationWarning: PyRange_New's 'repetitions' argument is deprecated
__main__:1: DeprecationWarning: xrange object comparision is deprecated; convert to list instead
__main__:1: DeprecationWarning: xrange object's 'start', 'stop' and 'step' attributes are deprecated
__main__:1: DeprecationWarning: xrange.tolist() is deprecated; use list(xrange) instead
[0, 1, 2]

Those are all the warnings I added: for PyRange_New's 'reps' argument, for
slicing, multiplication, comparison (did you really mean to take it out?),
the start/stop/step attributes, and tolist().

I did leave the range_concat function out, though, so the error

>>> xrange(1) + xrange(1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: cannot concatenate xrange objects

still changes into

>>> xrange(1) + xrange(1)  
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand types for +

but I don't see a problem with that. I also left out the 'contains'
implementation.

Still-not-understanding-*why*-<wink>-ly y'rs,
-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!