osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Catching an exception in a variable


Hello

try:
     a = 1 / 0
except ZeroDivisionError as ex:
    pass

>>> ex
Traceback (most recent call last):
  File "<pyshell#49>", line 1, in <module>
    ex
NameError: name 'ex' is not defined


Why variable ex doesn't exist ?