[Tutor] Comma Chameleon?

Robert Nyborg r.nyborg@telia.com
Tue, 26 Mar 2002 00:36:41 +0100


I'm sure other people on the list have elegant examples for this, =20
but this is what I've used for a similar problem:

###

import locale
locale.setlocale(locale.LC_ALL, 'US')
print locale.format('%s','123456789',1)

###

/RobertN

----- Original Message -----=20
From: "Curtis Larsen" <curtis.larsen@covance.com>
To: <tutor@python.org>
Sent: Monday, March 25, 2002 7:20 PM
Subject: [Tutor] Comma Chameleon?


> <grin>
> I'm  probably missing it, but isn't there some sort of formatting
> option for use with the 'print' command that will automagically insert
> commas into a number?  If not, what's the best Pythonic method to do
> this?  (Note: I don't need currency or a +/-: I just want 123456789 to
> look like 123,456,789.)
>=20
> Thanks!
> Curtis
>=20
>=20
>=20
> -----------------------------------------------------
> Confidentiality Notice: This e-mail transmission=20
> may contain confidential or legally privileged=20
> information that is intended only for the individual=20
> or entity named in the e-mail address. If you are not=20
> the intended recipient, you are hereby notified that=20
> any disclosure, copying, distribution, or reliance=20
> upon the contents of this e-mail is strictly prohibited.=20
>=20
> If you have received this e-mail transmission in error,=20
> please reply to the sender, so that we can arrange=20
> for proper delivery, and then please delete the message=20
> from your inbox. Thank you.
>=20
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor