Exception classes with properties
Gus Tabares
gustabares at verizon.net
Wed Jun 9 10:24:20 EDT 2004
Hello all,
I'm curious as to whether or not this is supported. I want to be able
to have an exception class that has properties. It seems as though
subclassing both Exception and object does not work. Like in the
following code:
class TestExcn(Exception, object):
def __init__(self, id = 'test_id'):
self.args = [id]
def set_id(self, id):
self.args[0] = id
def get_id(self):
print "Test"
return self.args[0]
id = property(get_id, set_id)
If I instantiate this class and try to raise the instance, I get a
TypeError. Is it possible to have an exception class with properties?
More information about the Python-list
mailing list