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

2008-05-11 Thread Eric Smith
Eric Smith <[EMAIL PROTECTED]> added the comment: Implemented in 3.0 as r63093. I'm closing this issue. I added the C code that does the grouping insertion as _PyString_InsertThousandsGrouping and _PyUnicode_InsertThousandsGrouping (in 3.0). This might be useful to others, although the API is

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

2008-05-11 Thread Eric Smith
Eric Smith <[EMAIL PROTECTED]> added the comment: Implemented in 2.6 as r63078. I'll port this to py3k shortly. __ Tracker <[EMAIL PROTECTED]> __ ___ Py

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

2008-05-09 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: > 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. Excellent! I didn't realise this code

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

2008-05-09 Thread Mark Summerfield
Mark Summerfield <[EMAIL PROTECTED]> added the comment: On 2008-05-09, Eric Smith wrote: > Eric Smith <[EMAIL PROTECTED]> 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

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

2008-05-09 Thread Eric Smith
Eric Smith <[EMAIL PROTECTED]> added the comment: > It isn't hard (in Python): It's more complex, because the "3" is locale dependent, and is allowed to be something like "3, then 2, then 3, then 1, repeating until the start of the string". See _group() in Lib/locale.py. In any event, the co

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

2008-05-09 Thread Mark Summerfield
Mark Summerfield <[EMAIL PROTECTED]> added the comment: On 2008-05-09, Mark Dickinson wrote: > Mark Dickinson <[EMAIL PROTECTED]> added the comment: > > 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. > > I

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

2008-05-09 Thread Eric Smith
Eric Smith <[EMAIL PROTECTED]> 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

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

2008-05-09 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: > 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. I agree with this, in principle. It might be some work to implement, though: for floats, Python gets

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

2008-05-09 Thread Mark Summerfield
New submission from Mark Summerfield <[EMAIL PROTECTED]>: 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