Catching an exception in a variable

ast nomail at com.invalid
Fri Aug 4 04:07:13 EDT 2017


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 ?



More information about the Python-list mailing list