Raise Error in a Module and Try/Except in a different Module

Jim jbo at cannedham.ee.ed.ac.uk
Mon Apr 4 06:26:21 EDT 2005


Issa-Ahmed SIDIBE wrote:
> I Have a function FUNC1 that is define in ModuleA. This function raise
> an exception EXCP1 (raise EXCP1), with EXCP1 a global variable in
> ModuleA.
> 
> In ModuleB, I have some classes that call FUNC1. I would like to catch
> EXCP1 and make some processing. How can I do that.
> 
> I tried in Module B
> 
> import ModuleA
> ...
> class():
>    ...
>    try: a = ModuleA.FUNC1
>    except ModuleA.EXCP1: print 'catch'
> 
> But It does not work. What is wrong?

I'm just back from holiday so rusty but I tried to do this w few weeks ago.

What's the error?

Jim



More information about the Python-list mailing list