[issue13349] Uninformal error message in index() and remove() functions

Petri Lehtinen report at bugs.python.org
Mon Nov 7 11:08:52 CET 2011

Petri Lehtinen <petri at digip.org> added the comment:

The good thing about this is ease of debugging. You can see which is the offending value that was not found.

On the other hand, the repr of a value might be very long:

>>> [].index(list(range(1000)))
ValueError: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
(many lines of numbers)
997, 998, 999] is not in list

Also, all values don't have a very informal repr:

>>> class Foo: pass
>>> [].index(Foo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: <__main__.Foo object at 0xb736f92c> is not in list


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list