473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Formatting Currency According to Locale

Hi everybody

Is there any way to make the most of locale.localeconv() in formatting currencies?

I can use many tricks as
locale.setlocale(locale.LC_ALL, locale.getlocale())
lc = locale.localeconv()

cash = 1427.48
print "%s%s" % (

lc['currency_symbol'],
locale.format('%.*f', (lc['frac_digits'],cash), 1))
€1.427,48

But that presumes many things, such as
lc['mon_grouping'] == lc['grouping'] # format uses the latter value, doesn't he?
lc['p_sign_posn'] == 3 # else i must change the format string,
# maybe building a mapping to order the pieces, splitting + and - cases...

I'm using...
Python 2.3.2 (#49, Oct 24 2003, 13:37:57) [MSC v.1200 32 bit (Intel)] on win32
.... and watching localeconv(), i also see many other not much documented details:
n_cs_precedes, n_sep_by_space...

Is it up to me to write a function to keep all these details into account?

Bye

Daniele
Jul 18 '05 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ian | last post by:
Hi guys, i'm trying to format the output of a record in access, which i am pulling from through php (odbc) and the formatting is set at 4 decimal places, which i don't want. i want currency and no...
6
by: H | last post by:
Hi All, Is it possible to detect a users regional settings, in particular - Currency? Thanks! Hellen.
6
by: Colin Fox | last post by:
Hi, all. This feels like a stupid question to me, but I've scoured the Internet (yes, the whole thing! :) and I can't find a single example of using the locale module to format money. So I...
4
by: Tommi Mäkitalo | last post by:
Hi I need to format floating-point-numbers with exact 2 digits after decimal point. I could use printf with "%.2f", but it don't use std::locale. Any ideas? -- Tommi Mäkitalo
2
by: Bob Dydd | last post by:
Hi Everbody Question Changing the regional settings ie. from UK to US AUS etc, Access retains the original currency format that the application was created in. So if an mdb that is written...
2
by: Rog | last post by:
Hi, I have a bilingual report that should print amounts as 1,234.00 in the English(US) part --which is no problem-- and as 1.234,00 in the French part. My regional settings are US. How can I...
1
by: thomson | last post by:
Hi all, i do have a Text Box for Amount , Almost all my forms are dealing with Amounts, In My Setup I specify that only 2 decimals are allowed , in all the amounts, How do i set this...
18
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have...
1
by: Malcolm Greene | last post by:
The locale module provides the ability to format dates, currency and numbers according to a specific locale. Is there a corresponding module for parsing locale's output to convert locale...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.