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

Ok, here is another solution that does not depend on args:

def PoliteException(e):
     E = e.__class__
     class PoliteException(E):
         def __init__(self):
             for arg in dir(e):
                 if not arg.startswith('_'):
                     setattr(self, arg, getattr(e, arg))
         def __str__(self):
             return str(e) + ", sorry!"
     PoliteException.__name__ = E.__name__
     return PoliteException()

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