try except ImportError failing to catch error!
Ben Gerblich
benji_75 at hotmail.com
Wed Sep 18 05:31:05 EDT 2002
I am importing all module files in the CWD. This part works fine.
I want to add the functionality to catch the error if there is a
typo in the imported module file. The following does not catch
the error!
try:
self.userDefs[file[:-3]]['class'] = __import__(file[:-3])
except ImportError, e:
print 'cant do it', e
I still get the runtime error:
Traceback (most recent call last):
File "./main.py", line 8, in ?
application = testApp()
File "/usr/lib/python2.1/site-packages/wxPython/wx.py", line 1581, in
__init__ _wxStart(self.OnInit)
File "./mainScript.py", line 3444, in OnInit
self.frame = MainFrame(None)
File "./mainScript.py", line 2836, in __init__
exec code
File "<string>", line 1, in ?
File "./Display.py", line 33, in __init__
self.line(5, 60, 15, 60,999)
TypeError: line() takes exactly 5 arguments (6 given)
I expect this error! as the '999' should not be there.
Why does not the 'cant to it' line print instead?
And is there a way for my handler routine to return the line-number of the
imported module file that caused the error?
Thanks,
Ben.
Im using:
Red Hat Linux 7.1
python2-2.1-5.i386.rpm
wxPython-2.3.2.1-1-Py21.i386.rpm
wxGTK-2.3.2-1.i386.rpm
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
More information about the Python-list
mailing list