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' >>> format(Decimal('nan'), '020,g') ' NaN' >>> format(Decimal('nan'), '0=20,g') '00000000000000000NaN' You can see that float literally follows PEP-3101: "If the width field is preceded by a zero ('0') character, this enables zero-padding. This is equivalent to an alignment type of '=' and a fill character of '0'." The advantage of decimal is that the user has the option to suppress commas. The behaviour of float is slightly easier to implement in C. So the options are: a) 020 is always equivalent to 0=20 b) 020 is not always equivalent to 0=20 Stefan Krah _______________________________________________ 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