[New-bugs-announce] [issue33560] tuple.index() could return a more explicit error message

Cyril Roelandt report at bugs.python.org
Thu May 17 12:20:20 EDT 2018


New submission from Cyril Roelandt <croeland at redhat.com>:

The tuple.index() method returns an error message that does not allow users to know what element was being looked for inside the tuple:

>>> ().index(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: tuple.index(x): x not in tuple

The list.index() method has a much better error message:

>>> [].index(1)   
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 1 is not in list

We could improve tuple.index() so that its behaviour becomes similar to that of list.index().

----------
messages: 316955
nosy: Cyril Roelandt
priority: normal
severity: normal
status: open
title: tuple.index() could return a more explicit error message
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33560>
_______________________________________


More information about the New-bugs-announce mailing list