Catching user defined exceptions from foreign modules

Derek Basch dbasch at
Mon Sep 30 04:22:47 CEST 2002

I have defined 2 simple modules, test1 and test2.
test1 calls the run function of test 2 which returns a
user defined TestError function. I then catch the
exception in test1 and perform a print. Heres the

So, this code works fine for me. However, I have 2
much larger modules that have the same code structure
but in these larger modules the test1 refuses to catch
the raised TestError unless I change the except clause

except test2.TestError:
    print 'fudge'

I know that TestError has been imported because I can
put a "print TestError" before the except clause in
test1 and I get "test2.TestError". Can anyone tell me
why I am having to put the test2.TestError instead of
just TestError? It confuses me even further that my
small test modules work like I would expect and it
doesn't work on the larger modules.

Thanks for the help,
Derek Basch


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

More information about the Python-list mailing list