default setting of unicode set

mathias palm mathias.palm at gmx.net
Mon Jul 29 04:42:55 EDT 2002


Hi, I am writing a program which is supposed to be international, 
meaning it works with different languages. Some languages like German or 
French use characters not part of the traditional ascii code. This can 
be circumvented by using unicode strings.

It is possible to set a default unicode (set to ascii) in site.py. This 
is clearly a setting by site. For programs which my use different 
unicode charackter set it would be useful to have a per user or better 
still a per program setting. I did not find any possiblity to do this. 
The function,  sys.setdefaultencoding() which sets the default unicode 
is even deleted in site.py.

I found a possibility to do this on linux systems: I run the code with 
python -C code.py. This inhibits python from loading site.py. Later I 
import an own site.py with changed default encoding. I think this is not
a good way. It is also put out of work to easy.

I am sure there is a reason for this behaviour, I cant see it however. 
Can anybody explain or tell me where to read about it? Why not setting 
the default unicode in a file like .pythonrc?

Is there a possibility to set a unicode default later on? I really dont 
want the users to get into the system and rewrite parts of python to 
take care of this problem, it might not even be possible on unix-like 
os. I also want users to start my program as straight forward as 
possible. The line #!/usr/bin/python -C (see above)is not a solution 
because it is to be circumvented to easily by say <python programname>..

Thanks
Mathias




More information about the Python-list mailing list