[Tutor] Formatting Numbers as Strings 33000.50 -> 33,000.50 ?

Rick Pasotto rick@niof.net
Wed, 28 Mar 2001 12:20:33 -0500


On Wed, Mar 28, 2001 at 04:17:25PM +0200, Remco Gerlich wrote:
> On Wed, Mar 28, 2001 at 10:06:23PM +0800, Jethro Cramp wrote:
> > Some of these are expected, but still none of them are X,XXX.XX. Is
> > this some peculiarity of my system (will try it on my Linux box
> > tomorrow)? Or should I be using the locale.format() function
> > differently. The idea of being able to change the formatting just by
> > changing the locale is very appealing (I have clients all over
> > Europe and formatting output to their locale would be appreciated by
> > them).
> 
> The correct command seems to be 'locale.format("%f", f, 1).
> 
> The '1' means that grouping is used, i.e. commas every three figures.
> As least, if I read the docs correctly
> (http://www.python.org/doc/current/lib/module-locale.html).
> 
> Did the setlocale(LC_ALL,"us") work? What's the output of
> locale.localeconv()?

When I do that [actually, locale.setlocale(locale.LC_ALL,"us")] I get
'locale setting not supported.' What do I need to do to get it
supported? I'm running debian and the 'locales' package is installed.

-- 
Freedom can be lost as surely tax by tax, regulation by regulation,
as it can be bullet by bullet, missile by missile.
		   Rick Pasotto email: rickp@telocity.com