By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,114 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,114 IT Pros & Developers. It's quick & easy.

Money formatting

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.