By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,592 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,592 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jim
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
Jul 18 '05 #2

P: n/a
On 4 Apr 2005 03:11:23 -0700, Issa-Ahmed SIDIBE <is*********@epfl.ch> 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?


You're not *calling* FUNC1 here, you're just assigning a reference to
it to the name 'a'. Try FUNC1() instead.

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Jul 18 '05 #3

P: n/a
Jim

You're not *calling* FUNC1 here, you're just assigning a reference to
it to the name 'a'. Try FUNC1() instead.

Oh yeah.
Jul 18 '05 #4

P: n/a
Am Montag, 4. April 2005 12:11 schrieb Issa-Ahmed SIDIBE:

Try:
import ModuleA
...
class():
...
try: a = ModuleA.FUNC1() ^^ <-- Actually call the method. except ModuleA.EXCP1: print 'catch'

HTH!

--
--- Heiko.
see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCURgqf0bpgh6uVAMRAjHiAJ9aEWVOwRMTorj3ryaEyX RGpklfjgCeIvFD
6CirS+hE5KqOen93O5sw0f8=
=qDMX
-----END PGP SIGNATURE-----

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.