[issue30477] tuple.index error message improvement

2017-05-27 Thread Brett Cannon
Changes by Brett Cannon : -- resolution: -> duplicate stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bu

[issue30477] tuple.index error message improvement

2017-05-26 Thread Martin Panter
Martin Panter added the comment: Also discussed in Issue 13349 -- nosy: +martin.panter superseder: -> Non-informative error message in index() and remove() functions ___ Python tracker

[issue30477] tuple.index error message improvement

2017-05-26 Thread schen
schen added the comment: What is the rationale for the inconsistency between tuples and lists here? ().index(0) ValueError: tuple.index(x): x not in tuple [].index(0) ValueError: 0 is not in list In this simple artificial case, it seems clear to me that the list version (which is similar to t

[issue30477] tuple.index error message improvement

2017-05-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Is it a performance worry? It really depends on what people are doing with their down. If indexing potentially missing values is common, there will be a performance impact. Also, the cost of a __repr__ varies wildly depending on the data (i.e. a colle

[issue30477] tuple.index error message improvement

2017-05-25 Thread Joe Jevnik
Joe Jevnik added the comment: As a more meta question: I have noticed that many error messages in the stdlib use PyErr_SetString, or choose to use the type name instead of the repr of the object. Is there a reason for this? I normally try to fill the error message with as much context as possi

[issue30477] tuple.index error message improvement

2017-05-25 Thread Joe Jevnik
Joe Jevnik added the comment: I agree, "%R in tuple" is enough information for me. This would also remove the need to manually repr the object. -- type: enhancement -> ___ Python tracker _

[issue30477] tuple.index error message improvement

2017-05-25 Thread Brett Cannon
Brett Cannon added the comment: I'm wondering if including the whole "tuple.index(%R)" part is still necessary? The traceback will tell you what method you called, so wouldn't "%R not in tuple" be enough? -- components: +Interpreter Core type: -> enhancement _

[issue30477] tuple.index error message improvement

2017-05-25 Thread Joe Jevnik
New submission from Joe Jevnik: The old error of tuple.index(x): x not in tuple seemed very confusing to me. It was also harder to quickly understand what the program was doing wrong. This saves people a second pass through the program under the debugger because they can just see what the inva