Skip to content

Glossary: Refactoring and Clean Code

Common Python errors (NameError, KeyError, ImportError, AttributeError)

Also written: NameError, KeyError, ImportError, AttributeError

NameError: code uses a name that doesn't exist, e.g. after renaming `p` in only some places. KeyError: a dict key is missing (`DELIVERY["Eugene"]`, or an unknown SKU). ImportError: an import can't find a name, e.g. a removed public name like `run`. AttributeError: an object or module has no such name, e.g. a misspelled name given to `monkeypatch.setattr`.

Where the book teaches it

Related terms

F2 (Rename Symbol)dict.getmonkeypatch