bob at redivi.com
Thu Mar 15 05:02:09 CET 2007
On 3/14/07, Dougal Graham <dougalg at gmail.com> wrote:
> Hi there,
> I am having a problem with figuring out how to set utf-8 as the
> default encoding for python. I have found various references to
> sitecustomize.py, but I'm not sure where to put that file. I just
> recently updated to python 2.5 using the .dmg file from python.org.
You really don't want to do that. The default encoding should always
be ASCII, setting it to anything else breaks some invariants.
The site-packages folder is one place to put stuff. It lives in
However, don't do it in this case. The reason you haven't been able to
find a good resource that tells you how to do it is because it's not
the correct thing to do.
Here's Frederik's thoughts on the setting (and he is certainly an
authority on Python's unicode implementation).
sys.setdefaultencoding() was added for experimentation during Unicode
development, and should not be used in production code. All sorts of
ugliness can happen if you mess around with the conversion rules
(especially if you use a variable-width encoding). It's not that hard
to write encoding-aware code, really.
More information about the Pythonmac-SIG