Re: Catching an exception in a variable

2017-08-04 Thread Steve D'Aprano
On Fri, 4 Aug 2017 06:21 pm, Ben Finney wrote about the unbinding of exception variable on leaving the except block: > I think this is a terrible idea. I agree it is a terrible idea. I'd go so far as to say it is the worst possible way for dealing with the program of exception reference loops, e

Re: Catching an exception in a variable

2017-08-04 Thread ast
"Ben Finney" a écrit dans le message de news:mailman.55.1501834898.28999.python-l...@python.org... "ast" writes: Ok, ty -- https://mail.python.org/mailman/listinfo/python-list

Re: Catching an exception in a variable

2017-08-04 Thread Ben Finney
"ast" writes: > Why variable ex doesn't exist ? Because of a deliberate decision made to delete it. Silently. This is documented: When an exception has been assigned using as target, it is cleared at the end of the except clause. This is as if except E as N: foo

Catching an exception in a variable

2017-08-04 Thread ast
Hello try: a = 1 / 0 except ZeroDivisionError as ex: pass ex Traceback (most recent call last): File "", line 1, in ex NameError: name 'ex' is not defined Why variable ex doesn't exist ? -- https://mail.python.org/mailman/listinfo/python-list