On 1/07/2011 12:57 PM, Chris Lambacher wrote:
...

Maybe there should be a __unicode__ method on the class? Maybe __str__
should set an explicit encoding?

Something like:

        def __unicode__(self):
                try:
                        return unicode(self.__call__())
                except pythoncom.com_error, details:
                        if details.hresult not in ERRORS_BAD_CONTEXT:
                                raise
                        return self.__repr__()

Yeah, that should exist - it does exist for makepy generated objects, just not dynamic ones. I'll add this.

        def __str__(self):
                return unicode(self).encode('utf-8')

I don't think this is the correct answer though due to the lack of precedent in other Python objects. Fortunately this all becomes moot in py3k.

Cheers,

Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to