Setting default output encoding

Torsten Bronger bronger at physik.rwth-aachen.de
Mon Aug 6 01:49:44 EDT 2007


Hallöchen!

I start a python script with subprocess from another Python script
with

    python = subprocess.Popen(["python", "myscript.py"],
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)

However, this child script has sys.stdout.encoding set to None,
which means that Unicode strings cannot be printed without trouble.
I tried

    environment = os.environ
    environment["LC_CTYPE"] = environment["LANG"] = "de_DE.UTF-8"
    python = subprocess.Popen(["python", "myscript.py"],
                              env = environment,
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)

for setting it to UTF-8, however, it didn't work.  Any idea on how
to achieve this?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                                      Jabber ID: bronger at jabber.org
                      (See http://ime.webhop.org for ICQ, MSN, etc.)



More information about the Python-list mailing list