Python

Learn Python programming from scratch

344 tutorials
12 of 344 tutorials
Jul 11, 2026· 8 min read

Python Decorators Explained

Learn what Python decorators are, how the @ syntax works, and why decorators are a fundamental tool for writing reusable, composable behaviour in Python.

PythonAdvanced
Jul 11, 2026· 7 min read

Return Values from Python Decorators

Learn how to preserve, inspect, and transform return values in Python decorators, and why the wrapper must always return the result of calling the original function.

AdvanceddecoratorsPython
Jul 11, 2026· 8 min read

Python Decorators with Parameters

Learn how to build Python decorators that accept their own arguments by adding a factory function layer, enabling configurable behaviour like custom log levels and retry counts.

AdvancedPython
Jul 11, 2026· 7 min read

Class-Based Decorators in Python

Learn how to use Python classes as decorators, why the __call__ method makes it possible, and when class-based decorators are cleaner than nested functions.

decoratorsPythonAdvanced
Jul 11, 2026· 8 min read

Real-World Uses for Python Decorators

Explore practical real-world applications of Python decorators including authentication, caching, rate limiting, input validation, and observability patterns.

decoratorsPythonAdvanced
Jul 11, 2026· 8 min read

Python Context Managers Explained

Learn what Python context managers are, how the with statement uses enter and exit methods, and why context managers guarantee cleanup regardless of exceptions.

context-managersPythonAdvanced+1
Jul 11, 2026· 7 min read

Use the with Statement in Python

Learn how to use the with statement in Python for file handling, lock management, and multiple context managers. Master the as clause and nested contexts.

AdvancedPythoncontext-managers
Jul 11, 2026· 8 min read

Create Custom Context Managers in Python

Learn how to create custom context managers in Python by implementing the enter and exit methods, turning any setup-and-teardown pattern into a reusable with statement.

PythonAdvancedcontext-managers
Jul 11, 2026· 8 min read

Python Context Managers with contextlib

Learn how the contextlib module simplifies working with context managers in Python, including the contextmanager decorator, suppress, redirect_stdout, and ExitStack.

context-managersAdvancedPython
Jul 11, 2026· 7 min read

Nested Context Managers in Python

Learn how to nest context managers in Python using commas, parenthesized multi-line syntax, ExitStack, and how nested contexts compose for complex resource management.

context-managersPythonAdvanced
Jul 11, 2026· 8 min read

Common Python Decorator and Context Manager Mistakes

Learn the most common mistakes with Python decorators and context managers, including missing functools.wraps, mutable defaults, exception suppression, and resource leaks.

decoratorsPythonAdvanced+1
Jul 11, 2026· 8 min read

Build a Resource Management Utility in Python

Build a complete resource management utility in Python that combines decorators and context managers to handle file operations, temporary resources, timers, and retries.

PythonAdvancedcontext-managers+1