How to set default encoding for print?

kj no.email at please.post
Sun Jan 31 10:38:04 EST 2010



It gets tedious to have to append .encode('utf-8') to all my unicode
strings when I print them, as in:

    print foobar.encode('utf-8')

I want to tell python to apply this encoding automatically to
anything argument passed to print.

How can I do this?

TIA!

K

PS: BTW, sys.setdefaultencoding is *not* the answer, since this
method gets removed by site.py...



More information about the Python-list mailing list