I would think that when the exception occurs the interpreter exits the block of code it is currently in and enters the exception block.
Thus the line n = 1/2 would never get executed. -Carl Ben Bush wrote: > 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 > > the code is here: > > try: > 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