Python guides
Every published Python guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Python guides
Most readLatest Python guides
Page 178 of 179Understanding Python Dynamic Typing at Runtime
Learn how Python's dynamic typing binds names to objects at runtime, why type hints don't enforce types, and how static and runtime checks can manage the tradeoffs.
Python Variable Shadowing Explained with Examples
Learn how Python variable shadowing works, why it can cause subtle bugs, and how to avoid it with clear naming and scoping discipline.
Python Local vs Nonlocal Variable: Scope Explained
Understand how Python resolves local and nonlocal variables in nested functions, when to use the nonlocal keyword, and how it differs from global.
Python Local vs Global Variable: Scope Explained
Understand how Python local and global variables differ, how assignment creates local variables, and when to use the global and nonlocal keywords.
Python nonlocal keyword: scope and closures
Learn how Python's nonlocal keyword works, when to use it in nested functions, and how it differs from global and local scope.
How the Python Global Keyword Affects Function Scope
Explains how the Python global keyword changes name resolution inside functions, when it is required, and where nonlocal or return values are better alternatives.
Python Nonlocal Variable: Scope and Usage
Understand the Python nonlocal variable keyword, its role in nested functions, and practical examples for closures.
Python Global Variables: Scope, Syntax, and Pitfalls
python global variable: Learn how Python global variables work: the global keyword, LEGB scope resolution, mutable object traps, thread safety, and when to avoid them.
Python Local Variable Scope: How It Works
Understand how Python local variables work: scope resolution, lifetime, closures, and common errors like UnboundLocalError.
Python Variable Scope: LEGB, global, and nonlocal
Learn how Python resolves names with the LEGB rule and how to use global and nonlocal to modify variables in module-level and enclosing scopes.