Given the contents t.pyof:
class Foo():
def RaiseBar(self):
raise Foo.Bar("hi")
class Bar(Exception):
pass
And running this on a python terminal:
>>> import t
>>> x = t.Foo()
>>> try:
... x.RaiseBar()
... except t.Foo.Bar as e:
... print e
...
hi
Isn't that what you were looking for?
Not sure what you did wrong with yours, I suggest you study the code more carefully.
source
share