On Sat, Dec 5, 2009 at 11:18 AM, Stefan Krah <stefan-use...@bytereef.org> wrote:
> Hi,
>
> I'm in the process of implementing formatting in my C-decimal module.
> Since testing is quite time consuming, I would appreciate a binding
> decision on how the following should be formatted:
>
>>>> from decimal import *
>>>> format(float(1234), '020,g')
> '0,000,000,000,001,234'
>>>> format(float(1234), '0=20,g')
> '0,000,000,000,001,234'
>>>>
>>>> format(Decimal(1234), '020,g')
> '0,000,000,000,001,234'
>>>> format(Decimal(1234), '0=20,g')
> '0000000000000001,234'

I like the Decimal behaviour better, but then I might be a little biased.  :-)

I find it odd that, for float formatting, the choice of fill character
affects whether commas are inserted:

Python 3.2a0 (py3k:76671, Dec  4 2009, 18:55:54)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> format(float(1234), '0=20,g')
'0,000,000,000,001,234'
>>> format(float(1234), '1=20,g')
'1111111111111111,234'
>>> format(float(1234), 'X=20,g')
'XXXXXXXXXXXXXXX1,234'

Mark
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to