[ python-Feature Requests-1052098 ] Seting defaultencoding through an environment variable

SourceForge.net noreply at sourceforge.net
Sat Oct 23 11:52:09 CEST 2004


Feature Requests item #1052098, was opened at 2004-10-22 12:11
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1052098&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 1
Submitted By: Diedrich Vorberg (diedrich)
Assigned to: Nobody/Anonymous (nobody)
Summary: Seting defaultencoding through an environment variable

Initial Comment:
Hallo, I'd love to be able to set Python's default
encoding on a per instance basis through an environment
variable like

  PYTHON_DEFAULT_ENCODING

or something. That would require a trivial modification
to site.py. 

Diedrich

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2004-10-23 11:52

Message:
Logged In: YES 
user_id=21627

If your application just needs a global setting, it can come
up with its own environment variable, right? Just set
MY_DEFAULT_ENCODING, and do

encoding=os.environ["MY_DEFAULT_ENCODING"]

Alternatively, try using locale.getpreferredencoding(); this
may allow to avoid an additional environment variable
altogether.

----------------------------------------------------------------------

Comment By: Diedrich Vorberg (diedrich)
Date: 2004-10-23 11:08

Message:
Logged In: YES 
user_id=442849

Even if the notion of default encoding were dropped from
Python, my application will need a global variable to have
one encoding that is used most of the time. That`s what I`m
using the default encoding for right now. Also, at least one
of the 3d party modules I'm using does the same and it makes
tons of sense. Changing the default encoding from within my
application doesn't work, because sys.setdefaultencoding()
gets removed (which makes sense, too, of course). So I need
a custom sitecustomize.py for every project which may or may
not be adhered to, depending on the PYTHONPATH variable.
That`s why a  PYTHON_DEFAULT_ENCODING variable would be very
usefull to me.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-10-23 10:32

Message:
Logged In: YES 
user_id=21627

Why do you want this change? In the long run, Python will
drop the notion of a default encoding; code should be
changed to avoid relying on the default encoding.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1052098&group_id=5470


More information about the Python-bugs-list mailing list