Tag

variable scope

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Mar 30, 2025 · Fundamentals

Master Python’s locals() and globals(): When and How to Use Them

Learn the essential differences between Python’s locals() and globals() functions, how they reveal variable scopes, how to modify them safely, and practical use cases such as dynamic variable creation, debugging, and performance considerations, all illustrated with clear code examples.

Pythondebuggingglobals
0 likes · 7 min read
Master Python’s locals() and globals(): When and How to Use Them
Test Development Learning Exchange
Test Development Learning Exchange
Mar 1, 2025 · Fundamentals

Python Function Nesting: Concepts, Applications, and Best Practices

This article explores Python function nesting, covering its basic concepts, practical applications, code examples, and important considerations for effective implementation in programming.

code encapsulationfunction nestingprogramming fundamentals
0 likes · 7 min read
Python Function Nesting: Concepts, Applications, and Best Practices
Test Development Learning Exchange
Test Development Learning Exchange
Sep 7, 2024 · Fundamentals

Understanding the Underscore (_) in Python: Uses and Conventions

This article explains the versatile uses of the underscore (_) in Python, covering temporary variables in REPL, loop placeholders, tuple unpacking, translation functions, numeric literals, naming‑conflict avoidance, protected and private attributes, and special magic methods, with clear code examples for each case.

Naming Conventioncode-examplesunderscore
0 likes · 6 min read
Understanding the Underscore (_) in Python: Uses and Conventions
Test Development Learning Exchange
Test Development Learning Exchange
Jul 31, 2024 · Fundamentals

Introduction to Variable Scope in Python

This article explains Python's four variable scope types—local, enclosing, global, and built‑in—through clear descriptions and runnable code examples that illustrate how each scope affects variable accessibility and program behavior.

Pythoncode examplesprogramming fundamentals
0 likes · 4 min read
Introduction to Variable Scope in Python
Python Programming Learning Circle
Python Programming Learning Circle
Mar 15, 2021 · Fundamentals

Understanding the global Statement in Python

The article explains how Python's global statement declares variables as global within a function, allowing modification of module‑level variables and preventing UnboundLocalError, with examples of incorrect usage, correct usage, multiple globals, and class‑based alternatives.

fundamentalsglobalprogramming
0 likes · 4 min read
Understanding the global Statement in Python
Python Programming Learning Circle
Python Programming Learning Circle
Jan 17, 2020 · Fundamentals

Master Python Variable Scope: The LENGB Guide Explained

This article explains Python’s static variable scope, introducing the LENGB model (Local, Enclosing, nonlocal, Global, Built‑in) and demonstrates how Python resolves names through examples that illustrate common pitfalls such as NameError and the correct use of global and nonlocal keywords.

LENGBPythonglobal
0 likes · 4 min read
Master Python Variable Scope: The LENGB Guide Explained
Python Programming Learning Circle
Python Programming Learning Circle
Jan 11, 2020 · Fundamentals

Why Python’s for‑loop Variables Leak Outside the Loop (and What It Means)

This article explores why Python’s for‑loop index variables remain visible after the loop, examines the underlying bytecode and AST handling, and explains why this behavior persists and can be useful in real‑world code.

ASTLanguage DesignPython
0 likes · 11 min read
Why Python’s for‑loop Variables Leak Outside the Loop (and What It Means)