[issue18738] String formatting (% and str.format) issues with Enum
Eric V. Smith
report at bugs.python.org
Wed Aug 14 22:57:47 CEST 2013
Eric V. Smith added the comment:
I don't think it's possible for int (PyLong) to handle a decision to format itself as a string. Personally, I'd like this:
>>> format(3, 's')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown format code 's' for object of type 'int'
To continue to be an error.
This is exactly why the __format__ protocol was added: so a type could make a decision on how it should format itself. My only concern is the fragility of the proposed solution.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18738>
_______________________________________
More information about the Python-bugs-list
mailing list