how to get a return value from an exception ?

Shagshag13 shagshag13 at yahoo.fr
Thu Jul 25 10:08:04 EDT 2002


hello,

i need to raise an exception which "carry" some data... i think that it's something like :

class MyException(Exception):

 def __init__(self, *args):
  Exception.__init__(self, args)

>>> raise MyException('one', 2, 'three')
Traceback (most recent call last):
  File "<pyshell#66>", line 1, in ?
    raise MyException('one', 2, 'three')
MyException: ('one', 2, 'three')

but them how to access to 'one', 2, and 'three' ?

it's ok if i do it like in "dive in python"

>>> class MyError(Exception):
def __init__(self, value):
    self.value = value
def __str__(self):
    return `self.value`

but here what does the `` stand for ?

thanks,

s13.





More information about the Python-list mailing list