pipeline encoding

"Martin v. Löwis" martin at v.loewis.de
Thu Dec 6 14:23:43 EST 2007


> Are there any command line option for telling python what encoding to
> use for stdout?

Not a command line option. However, you can wrap sys.stdout with a
stream that automatically performs an encoding. If all your print
statements output Unicode strings, you can do

sys.stdout = codecs.getwriter("utf-8")(sys.stdout)

HTH,
Martin



More information about the Python-list mailing list