Real Python Tutorials

Python Scope & the LEGB Rule: Resolving Names in Your Code
NEW

The LEGB Rule & Understanding Python Scope

In this step-by-step video course, you'll learn what scopes are, how they work, and how to use them effectively to avoid name collisions in your code.

May 27, 2025 intermediate python