[Tutor] Even More Converter!

Rolando Pereira finalyugi at sapo.pt
Sat Mar 22 19:11:18 CET 2008


Alan Gauld wrote:
> 
> 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...
> 

There is always the shell command "locale".

___________________________

import subprocess

output = subprocess.Popen("locale | grep NUMERIC", shell=True, \
                                stdout=subprocess.PIPE)
print output.communicate()[0]

LC_NUMERIC="pt_PT.UTF-8" (In my case)

___________________________

The problem with this is that it assumes the default shell is properly
  setted up (which may not be the case, for example this output happens
in Bash, but in ZSH it gives en_US.UTF-8), which may not be the case.

-- 
                       _
ASCII ribbon campaign ( )
 - against HTML email  X
             & vCards / \


More information about the Tutor mailing list