Christoph Zwerschke wrote:
> But my __getattr__ solution does not work either, since the attributes 
> are set to None when initialized, so __getattr__ is never called.

Here is a simple solution, but it depends on the existence of the args 
attribute that "will eventually be deprecated" according to the docs:

def PoliteException(e):
     E = e.__class__
     class PoliteException(E):
         def __str__(self):
             return str(e) + ", sorry!"
     PoliteException.__name__ = E.__name__
     return PoliteException(*e.args)

try:
     unicode('\xe4')
except Exception, e:
     p = PoliteException(e)
     assert p.reason == e.reason
     raise p
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to