Back to search

What is a namespace in Python?

A namespace is a mapping from names to objects, and scope decides which namespace Python checks first.

Python Medium Theory

What is a namespace in Python?

A namespace is a mapping from names to objects, and scope decides which namespace Python checks first.

  • Local, enclosing, global, builtins
  • LEGB lookup rule
  • Avoid name collisions

What is a namespace in Python?