summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-11-24 05:53:26 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-11-24 05:53:26 (GMT)
commit8f2c4eed93fd0aab1fbcce1e8e57ffea358c4901 (patch)
treee6942e92b6dc369f2f790d0350750d49e0516245 /Doc
parent3684c8771e598af1737632a7a1c78d065bf77b94 (diff)
downloadcpython-8f2c4eed93fd0aab1fbcce1e8e57ffea358c4901.zip
cpython-8f2c4eed93fd0aab1fbcce1e8e57ffea358c4901.tar.gz
cpython-8f2c4eed93fd0aab1fbcce1e8e57ffea358c4901.tar.bz2
SF bug #1071566: moneyfmt recipe in decimal documentation has error
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libdecimal.tex4
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/lib/libdecimal.tex b/Doc/lib/libdecimal.tex
index 5131ef9..7d461c2 100644
--- a/Doc/lib/libdecimal.tex
+++ b/Doc/lib/libdecimal.tex
@@ -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)