python3 - the hardest hello world ever ?
"Martin v. Löwis"
martin at v.loewis.de
Fri Oct 17 00:23:15 CEST 2008
> I meant setting the default encoding which is used by print (e.g.) when
> outputting the internal unicode string to a file.
Having such a thing would be conceptually wrong. What encoding should
be used depends on the file - different files may have different
encodings. When opening a file, you need to specify the encoding.
> As far as I understood, currently I am fixed to setting either
> the 'locale' or to switch settings for each output file (by settting
> the _encoding property.
That's not true. You can also specify the encoding when opening the file
> I wished I could override the locale settings within a Python script.
You can monkey-patch locale.getpreferredencoding, which is used when
determining what encoding to use when opening new files. I don't
recommend doing so, though.
More information about the Python-list