[New-bugs-announce] [issue2802] str.format() :n integer output

Mark Summerfield report at bugs.python.org
Fri May 9 16:08:08 CEST 2008

New submission from Mark Summerfield <mark at qtrac.eu>:

In Py30a5 the 'n' format option is not v. useful for integers:

>>> for x in range(8):
	print("{0:n} ".format(10**x), end="")
1 10 100 1,000 10,000 100,000 1e+06 1e+07

This is because it behaves like g once a number grows large. That makes
sense for floats, but since Python has unlimited size integers there is
currently no built-in way to get, 10**6 to output as 1,000,000 (or using
whatever the user's locale-dependent separator is). (It is easy to write
a suitable function for this, but it just seems that n is a bit of a
teaser in this regard.)

I think that n should stay the same for floats, but for integers should
never switch to g, but just use as many separators as needed.

messages: 66471
nosy: mark
severity: normal
status: open
title: str.format() :n integer output
type: feature request
versions: Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list