I just wanted to thank Python for making encodings so easy!

I recently discovered that one of the tools I use stores everything in UTF-8, and so I was getting some off-by-one errors because I was treating things as strings. I added

    def __unicode__(self):
        return str(self).decode('utf-8')

to the base object in the hierarchy, and wrapped my popen calls with readers and writers:

    file_in, file_out, file_err = _os.popen3(self.command)
    file_in = codecs.getwriter(self.encoding)(file_in)
    file_out = codecs.getreader(self.encoding)(file_out)
    file_err = codecs.getreader(self.encoding)(file_err)

and voilą! Everything works perfect!

Thank you Python!

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to