On 15 Feb, 2008, at 0:11, Christopher Barker wrote: > Robin Dunn wrote: >> Just replace sys.stdout with an object with a write() method that >> does >> what you want. > > I don't think that will do it, as "print" will have already converted > the object to a string, and it does that with str(), which calls > object.__str__, which used the default encoding.... > > oh well, I'm really just whining, but this transition to unicode is > pretty painful!
On my system print u"text" already does the right thing, even when the text contain non-ascii characters. This is with the system install of python. >>> import sys >>> sys.getdefaultencoding() 'ascii' >>> sys.stdout.encoding 'UTF-8' That's because the system (OSX 10.5) has set an environment variable that Python knows about: LANG=en_US.UTF-8. YMMV, Ronald > > > -Chris > > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R (206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > [EMAIL PROTECTED] > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig