list.index(..) -> TypeError bug or feature?

Pearu Peterson pearu at
Tue Feb 6 08:42:55 EST 2001

In Python 2.1a2 I get TypeError exception from list index() method even if
the list contains given object:

>>> from gmpy import mpz
>>> a = [mpz(1),[]]
>>> a.index([])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: coercion to gmpy.mpz type failed

while in Python 2.0b2 it works:

>>> a = [mpz(1),[]]
>>> a.index([])

Is this Python 2.1a2 bug or gmpy bug? Or my bug and Python 2.1 feature?


More information about the Python-list mailing list