Re: what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Laurent Claessens
I would. The io module is more recent an partly replaces codecs. The latter remains for back compatibility and whatever it can do that io cannot. I've a naive question : what is wrong with the following system ? class MyStdOut(object): def __init__(self): self.old_stdout=sys.std

Re: what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Terry Reedy
On 3/7/2012 3:57 PM, Peter Kleiweg wrote: In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') I guess the seco

what is best method to set sys.stdout to utf-8?

2012-03-07 Thread Peter Kleiweg
In Python 3, there seem to be two ways to set sys.stdout to utf-8 after the script has started: sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8') I guess the second is better. At start-up, type(sys.stdout) i