I wrote the following code to test the use of "try...exception",
and I want n to be printed out. However, the following code's output is:
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\py\use\tryExVa.py", line 7, in ?
print n
NameError: name 'n' is not defined
File "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\py\use\tryExVa.py", line 7, in ?
print n
NameError: name 'n' is not defined
the code is here:
try:
m=2/0
n=1/2
except ZeroDivisionError:
pass
print "Yes!!! This line will always print"
print n
m=2/0
n=1/2
except ZeroDivisionError:
pass
print "Yes!!! This line will always print"
print n
-- http://mail.python.org/mailman/listinfo/python-list