Exception classes with properties

G

Gus Tabares

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top