Skip to content

Instantly share code, notes, and snippets.

@ssanderson
Created December 9, 2015 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssanderson/90f7c3c5cc920f1a684c to your computer and use it in GitHub Desktop.
Save ssanderson/90f7c3c5cc920f1a684c to your computer and use it in GitHub Desktop.
except-blocks unconditionally delete the bound name in Python 3
In [2]: e = 3
In [3]: x = {}
In [4]: try:
...: x['a']
...: except Exception as e:
...: pass
...:
In [5]: e
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-9ffbf43126e3> in <module>()
----> 1 e
NameError: name 'e' is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment