[Pythonmac-SIG] How to print unicode to OS-X Terminal.app

Kent Johnson kent37 at tds.net
Thu Feb 14 04:12:05 CET 2008


Christopher Barker wrote:
> I suppose what I would like is if I could change the default encoding 
> that str() uses -- or at least change it to "replace" or "ignore" mode.

You can, with sys.setdefaultencoding(). See here for discussion of how:
http://blog.ianbicking.org/illusive-setdefaultencoding.html

and here for arguments that this is a bad idea (mostly because it makes 
your code non-portable):
http://faassen.n--tree.net/blog/view/weblog/2005/08/02/0

Kent


More information about the Pythonmac-SIG mailing list