[docs] [issue13790] In str.format an incorrect error message for list, tuple, dict, set

Terry J. Reedy report at bugs.python.org
Sat Jan 21 06:56:25 CET 2012

Terry J. Reedy <tjreedy at udel.edu> added the comment:

OK, the example of an empty format spec should be dropped. Let people figure it out ;-).

>>> format([], 'd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'str'

One possibility is to give (str of) the object instead of the type:

ValueError: Unknown format code 'd' for object '[]'

The downside is a long message for long strings. It would need to be limited (as is done in test error reports).


Python tracker <report at bugs.python.org>

More information about the docs mailing list