FOMO Daily
Feed
Real Python·

Namespaces in Python

Languages & ToolingPythonNamespacesScope

TL;DR

Reusing names in Python can make it confusing to know which variable your code will access. The tutorial explains how namespaces separate names and how Python looks them up in local, enclosing, global, then built-in scopes—the LEGB rule. Understanding these rules helps you avoid naming conflicts and unexpected variable-access errors.

Read the original post Sign in to mark as read or skip