Test Development Learning Exchange
Mar 22, 2024 · Fundamentals
Understanding Python Scope Rules: Global, Local, Enclosing, and Built‑in
This article explains Python's four scope levels—global, local, enclosing (non‑local), and built‑in—describes how the LEGB lookup order works, and provides clear code examples demonstrating variable access and modification in each scope.
LEGBScopecode examples
0 likes · 5 min read