Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread Peter Otten
jr wrote: >> >>> import locale >> >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252') >> 'English_United States.1252' > Just tried the first 2 commands on win XP, Python 2.5 under Idle. > An Error is raised: "unsupported locale setting" (lib/locale.py in > setlocale, line 476). > Ac

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread Jerry
Replace the conv function call with locale.localeconv. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread jr
Hi, Bernard. Just tried the first 2 commands on win XP, Python 2.5 under Idle. An Error is raised: "unsupported locale setting" (lib/locale.py in setlocale, line 476). Actually I get the error also under Python 2.4.3 Any idea what I'm missing? Thanks in advance. Jürgen Bernard wrote: > >>> import l

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Ben Finney
Richard Kessler <[EMAIL PROTECTED]> writes: > I am relatively new to Python. Love it, but I find things that I > can do easily in .NET and cannot find a way to do in Python. I need > to format a number as currency, for example 12343.56 to $12,343.56. > > In C# all I need to do is decimal x = 1234

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Bernard
>>> import locale >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252') 'English_United States.1252' >>> conv = locale.localeconv() >>> x = 1234567.8 >>> locale.format("%d", x, grouping=True) '1,234,567' >>> locale.format("%s%.*f", (conv['currency_symbol'], conv['int_frac_digits'], >>>

Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Richard Kessler
I am relatively new to Python. Love it, but I find things that I can do easily in .NET and cannot find a way to do in Python. I need to format a number as currency, for example 12343.56 to $12,343.56. In C# all I need to do is decimal x = 12343.56 then x.ToString("$###,###.00"); I cannot find