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.stdout
    def write(self,x):
        try:
            if isinstance(x,unicode):
                x=x.encode("utf8")
        except (UnicodeEncodeError,UnicodeDecodeError):
            sys.stderr.write("This should not happen !")
            raise
        self.old_stdout.write(x)
sys.stdout=MyStdOut()


... well ... a part of the fact that it is much longer ?


Laurent Claessens
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to