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 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)

Assignments

  1. Chapter Exercises 11 on Codio due this week.
  2. Lab10 (do pre-lab first on D2L)
  3. Project07 due in 1 week