Exception classes with properties

Discussion in 'Python' started by Gus Tabares, Jun 9, 2004.

  1. Gus Tabares

    Gus Tabares Guest

    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?
    Gus Tabares, Jun 9, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    0
    Views:
    903
    Nathan Sokalski
    Oct 17, 2005
  2. =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?=

    CompositeControls: ViewState properties w/ Mapped properties probl

    =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?=, Jan 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,137
    Steven Cheng[MSFT]
    Jan 19, 2006
  3. Kent Lichty
    Replies:
    0
    Views:
    832
    Kent Lichty
    Apr 16, 2004
  4. Victor Porton
    Replies:
    1
    Views:
    696
    Steven T. Hatton
    Aug 29, 2004
  5. Wardie
    Replies:
    4
    Views:
    488
    Wardie
    Nov 8, 2006
Loading...

Share This Page