[Tutor] Even More Converter!

Alan Gauld alan.gauld at btinternet.com
Sat Mar 22 18:30:09 CET 2008


<wackedd at mac.com> wrote
> When Python gives me the answer to my conversion, 
> is there a way to create it so every 3 numbers a 
> comma is inserted?

Bear in mind that the use of commas is very much a 
local thing. In some parts of the world periods are used 
and a comma indicates a decimal point so

123,456

could be 123 thousand 456 or 123 point 456 depending 
on where the reader is from.

If that is important you might need to investigate a locale specific 
way of defining the seperator. I know Windows has hooks to get 
it from the local settings but I'm not sure about *nix and I don't 
know if Python has a generic way.

This might not matter to you in practice , but I thought I'd 
mention it just in case...

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list