as clause
The part of an except clause, as name, that gives you the exception object so you can read its message.
In more detail
except ValueError as err: lets you print err or log it. The name is removed when the handler ends. The same word as appears in import ... as and with ... as, where it also binds a name.
Related terms
- try statement — The statement that runs a block of code and, if a listed exception happens there, runs an except block instead of letting the program stop.
- exception — An error object a program raises to stop normal flow and report that something went wrong.
Taught in
- Exceptions: try, except, else, finally — Hands-on Python: Complete Video Course & Book
- Raising, And Writing Your Own Exception — Hands-on Python: Complete Video Course & Book