469,936 Members | 2,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

Money formatting

I'm trying to format an integer as money. As far as i can see there is
no strfmon() in python. I also tried the
locale.format("%.2f",100000000,True) way but it does not even made the
grouping work. I tried to hack some locale-related files (especially
/usr/share/i18n/locales/tr_TR), but it dosn't worked either. Of course I
can use brute force and make grouping and money formatting to work by
hand but I think it's not a very pythonic way. Are there any library
functions which I'm missing? Or will I have to use brute force?

My system is:
Debian GNU/Linux: Sarge
Python Version: Python 2.3.4
Locale: tr_TR.ISO8859-9

--
Love Respect GNU/Linux
################################################## ######################
<MrCurious> by the power of greyskull
<MrCurious> someone tell me the ban to place
<Sopwith> mrcurious: *.debian.org, *.novare.net
<philX> *.debian.org. that's awesome.
-- Seen on LinuxNet #linux
################################################## ######################
Tonguç Yumruk

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA58wh1xWu4MLSyoYRAqQcAJ4zHRG469c4EBUEj158NF DohvfGfgCfZ0+R
AfWmugq0+SZAN+CGrT9iCd0=
=qN2O
-----END PGP SIGNATURE-----

Jul 18 '05 #1
1 2008
Tonguc Yumruk <to**********@member.fsf.org> wrote in message news:<ma**************************************@pyt hon.org>...
I'm trying to format an integer as money. As far as i can see there is
no strfmon() in python. I also tried the
locale.format("%.2f",100000000,True) way but it does not even made the
grouping work. I tried to hack some locale-related files (especially
/usr/share/i18n/locales/tr TR), but it dosn't worked either. Of course I
can use brute force and make grouping and money formatting to work by
hand but I think it's not a very pythonic way. Are there any library
functions which I'm missing? Or will I have to use brute force?


I get the same problem:
import locale
locale.format('%.2f', 1234.56, True) '1234.56'

But this seems to fix it:
locale.setlocale(locale.LC_NUMERIC, 'en_US.ISO8859-1') 'en_US.ISO8859-1' locale.format('%.2f', 1234.56, True)

'1,234.56'
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Batista, Facundo | last post: by
11 posts views Thread by ZRexRider | last post: by
3 posts views Thread by Robby Russell | last post: by
4 posts views Thread by Jerry | last post: by
1 post views Thread by Woodies_46 | last post: by
7 posts views Thread by paulmac106 | last post: by
1 post views Thread by Jaros³aw Kozik | last post: by
4 posts views Thread by Ian Semmel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.