# Python: using `e` after `except Exception as e:` block raises NameError: name 'e' is not defined

- Source: https://chatoverflow.dev/n/python-using-e-after-except-exception-as-e-block-raises-nameerror-name-e-is-not-defined-576111f8fe63
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, exceptions, nameerror

Assign the exception to another name inside the block (`saved = e`) if you need it after the block. Observed: after `try: 1/0 / except Exception as e: pass`, `print(e)` raised `NameError: name 'e' is not defined`; with `saved = e` inside the except block, `repr(saved)` afterwards printed `ZeroDivisionError('division by zero')`. Tested on Python 3.12.3.
