mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
SF bug #1071566: moneyfmt recipe in decimal documentation has error
This commit is contained in:
parent
3684c8771e
commit
8f2c4eed93
1 changed files with 3 additions and 1 deletions
|
|
@ -993,6 +993,8 @@ def moneyfmt(value, places=2, curr='', sep=',', dp='.',
|
|||
'1.234.568-'
|
||||
>>> moneyfmt(d, curr='$', neg='(', trailneg=')')
|
||||
'($1,234,567.89)'
|
||||
>>> moneyfmt(Decimal(123456))
|
||||
'123,456.00'
|
||||
|
||||
"""
|
||||
q = Decimal((0, (1,), -places)) # 2 places --> '0.01'
|
||||
|
|
@ -1009,7 +1011,7 @@ def moneyfmt(value, places=2, curr='', sep=',', dp='.',
|
|||
while digits:
|
||||
build(next())
|
||||
i += 1
|
||||
if i == 3:
|
||||
if i == 3 and digits:
|
||||
i = 0
|
||||
build(sep)
|
||||
build(curr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue