Tagged articles

nonlocal

5 articles · Page 1 of 1
Subtle Storm
Subtle Storm
Jul 5, 2025 · Fundamentals

Understanding Python Closures: Concepts, Uses, and Common Pitfalls

This article explains what Python closures are, how they capture outer‑scope variables, demonstrates typical patterns such as data hiding, stateful counters, factory functions, callbacks and lazy evaluation, and highlights important pitfalls like memory use and late‑binding bugs.

Functional ProgrammingPythoncallback
0 likes · 9 min read
Understanding Python Closures: Concepts, Uses, and Common Pitfalls
php Courses
php Courses
Apr 8, 2025 · Fundamentals

Understanding Python Closures and Decorators

This article explains Python closures and decorators, detailing their definitions, formation conditions, practical examples, common use cases, and how decorators rely on closures, while providing code snippets for counters, timing, and repeatable execution.

Function WrappingHigher-Order FunctionsPython
0 likes · 14 min read
Understanding Python Closures and Decorators
Python Programming Learning Circle
Python Programming Learning Circle
May 19, 2020 · Fundamentals

Understanding Python Closures, Generators, and the nonlocal Keyword with Multiple Implementation Methods

This article explains how to create a counter using Python closures, explores three different implementations—including mutable objects, generators, and the nonlocal keyword—while clarifying the behavior of immutable vs. mutable objects and demonstrating the practical use of nonlocal in nested functions.

Pythonclosurefundamentals
0 likes · 7 min read
Understanding Python Closures, Generators, and the nonlocal Keyword with Multiple Implementation Methods
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.

LENGBVariable Scopeglobal
0 likes · 4 min read
Master Python Variable Scope: The LENGB Guide Explained