[issue2802] str.format() :n integer output

Eric Smith report at bugs.python.org
Fri May 9 16:42:21 CEST 2008


Eric Smith <eric at trueblade.com> added the comment:

The reason for this is that 'n' is defined in PEP 3101 as being a float
format only, and the rule is that if an integer sees a float format, it
does a float conversion and then prints the float with the supplied format.

I'd be okay with adding 'n' as an integer format, with the loose
definition of "just like 'd', but adding thousands separators".

As to the implementation, the OS supplied float formatting does not add
thousands separators.  I added the function add_thousands_grouping() to
Python/pystrtod.c in order implement this for floats.  It would be easy
to make this same code work for integers (and in fact it might already
work, although there are probably memory allocation issues to deal with).

Maybe we should bring up modifying the PEP on python-dev or python-3000.

This issue exists in 2.6 as well.

----------
components: +Interpreter Core
versions: +Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2802>
__________________________________


More information about the Python-bugs-list mailing list