Wrapping stdout in a codec
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Oct 22 02:20:20 EDT 2007
On Mon, 22 Oct 2007 02:41:17 +0000, JKPeck wrote:
> We want to wrap the stdout device in a codec in order to decode output
> transparently according to a particular code page (which might not be
> the system code page). However, codec.open requires a filename, and
> stdout may be a tty or otherwise anonymous. How can we accomplish
> this wrapping?
The `codecs` module has more than just the `codecs.open()` function. Try
something like this::
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list