2.2.2 Annoyance

Jegenye 2001 Bt nospam at nowhere.hu
Sat Nov 22 17:29:49 EST 2003


Caveat:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34)
Type "help", "copyright", "credits" or "l
>>> l = [1,2,3]
>>> l[1]
2
>>> l.__getitem__(1)
2
>>> l.__getitem__(slice(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: an integer is required
>>>

According to the manuals of Python 2.2.2, passing a slice object to
__getitem__ is all right and should work...
Cost a few (grey) hairs of mine, while debugging a largish program, this is
not so.
Would someone care to pass on this info to whom this  may concern?

For Python 2.3  passing a slice object to __getitem__ does work though.

Best,
Miklós







More information about the Python-list mailing list