[ python-Bugs-1071566 ] moneyfmt recipe in decimal documentation
has error
SourceForge.net
noreply at sourceforge.net
Wed Nov 24 06:53:50 CET 2004
Bugs item #1071566, was opened at 2004-11-23 04:56
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1071566&group_id=5470
Category: Documentation
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Anna Ravenscroft (annarave)
Assigned to: Nobody/Anonymous (nobody)
Summary: moneyfmt recipe in decimal documentation has error
Initial Comment:
In the new 2.4c1 documentation for decimal, section
5.6.7 Recipes, there is a moneyfmt function - which
mostly works pretty well. It adds a separator between
every 3 digits.
Unfortunately, it adds the separator even when there
are no further digits. So, for example, you can end up
with:
$,437.00
instead of
$437.00
I propose a simple fix:
while digits:
append(next())
i += 1
if i % 3 == 0: append(sep)
if result[-1] == sep: result.pop() # add this line
This would make the moneyfmt function much more usable.
Anna
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-11-24 00:53
Message:
Logged In: YES
user_id=80475
Thanks for the timely bug report.
Adopted a simpler solution -- only adding a separator when
more digits remain:
- if i == 3:
+ if i == 3 and digits:
Also added at test to cover this case.
See Doc/lib/libdecimal.tex 1.22
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1071566&group_id=5470
More information about the Python-bugs-list
mailing list