Scope

Scope is the textual region of a program where a particular namespace is directly accessible. That is, what namespace is available?

Readings from the book The Practice of Computing Using Python.

Section 9.6: Scope—The Full Story

Videos

  1. Unqualfied Names (LEGB)
  2. Unqualified names do not have a dot.
    Scope rules for unqualified names:

    • Local: inside the current function
    • Enclosing: in an outer function
    • Global: the module's global names
    • Built-in: Python's standard library

    1. LEGB (Video)
  3. Qualfied Names (LCB)
  4. Qualified names do not have a dot.
    Scope rules for qualified names:

    • Local: inside the current object
    • Class: inside the class definition
    • Base: inside the base class

    1. LCB (Video)
  5. Project10