[issue2110] Implement __format__ for Decimal

Mark Dickinson report at bugs.python.org
Tue Mar 17 22:18:40 CET 2009


Mark Dickinson <dickinsm at gmail.com> added the comment:

New version of decimal_n_format.patch, with support for the thousands 
separator (PEP 378).  As discussed on python-dev, during zero-padding the 
patched code adds an extra '0' on the left to avoid a leading ',' if 
necessary.  For example:

>>> format(Decimal('123456'), '08,')
'0,123,456'

The Decimal.__format__ method (and support code) had to be fairly 
significantly reworked.  However, I'm reasonably confident that this code 
is correct:  a patch review would be welcome if anyone has the time;  
otherwise I'll commit this in a couple of days or so.

----------
stage:  -> commit review
type:  -> behavior
Added file: http://bugs.python.org/file13353/decimal_n_format2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2110>
_______________________________________


More information about the Python-bugs-list mailing list