[issue18738] String formatting (% and str.format) issues with Enum

Eric V. Smith report at bugs.python.org
Wed Aug 14 23:38:37 CEST 2013


Eric V. Smith added the comment:

> So what you're saying is that '{:}' is empty, but '{:10}' is not?

Yes, exactly. The part before the colon says which argument to .format() to use. The empty string there means "use the next one". The part after the colon is the format specifier. In the first example above, there's an empty string after the colon, and in the second example there's a "10" after the colon.

Which is why it's really easier to use:
format(obj, '')
and
format(obj, '10')
instead of .format examples. By using the built-in format, you only need to write the format specifier, not the ''.format() "which argument am I processing" stuff with the braces and colons.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18738>
_______________________________________


More information about the Python-bugs-list mailing list