Functions, LEGB Scope & Recursion

Unit 2: Control Flow, Scope & Recursion · 9 min read

Parameter passing by object reference, the mutable-default-argument trap, LEGB lookup, closures, and memoized recursion.

Key Concepts

  • Default arguments evaluate once at def time
  • LEGB resolution and UnboundLocalError
  • Positional-only (/), keyword-only (*), *args, **kwargs
  • Base cases, stack depth, and @lru_cache

Official Python Docs

Back to Python Notes Hub