Pages

Topics

Tools

↑↓navigate↵openescclose

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

Latest Python guides

Editorial illustration of Python variable naming showing valid and invalid identifier examples with underscore and keyword symbols.
Python

Python Variable Naming Rules and Conventions

Understand Python's identifier syntax, reserved keywords, built-in shadowing, and PEP 8 naming conventions so your variable names are legal, clear, and maintainable.

python identifiersPEP 8naming conventionscode quality
Illustration of two variables exchanging positions in Python using tuple unpacking, with a clean code editor background.
Python

How to Swap Variables in Python with Tuple Unpacking

Learn how to swap variables in Python with tuple unpacking, including evaluation order, list swaps, edge cases, and when a temporary variable is still useful.

tuple unpackingvariable assignmentpython idiomscode readability
Illustration showing two variables exchanging values through a bidirectional swap arrow, representing Python multiple assignment
Python

Python Multiple Assignment: Syntax and Behavior

Python's multiple assignment evaluates the right side before assigning. This article covers variable swapping, iterable unpacking, star expressions, and common failure cases.

multiple assignmenttuple unpackingpython syntaxvariable swapping
Diagram showing Python variable initialization with None and empty list options.
Python

Python Variable Initialization: Avoiding Common Pitfalls

python variable initialization: Learn how to initialize Python variables correctly, avoid mutable default pitfalls, and choose between None, empty values, and type hints.

Pythonvariable initializationNonetype hints
Illustration of Python variable names bound to shared objects, showing reference semantics versus value copying.
Python

Python Variable Assignment: Names, References, and Mutability

Understand how Python variable assignment binds names to objects, why rebinding differs from mutation, and how aliasing affects real code.

pythonvariable assignmentreference semanticsmutability
Illustration of Python variable declaration with type hints and scope
Python

Python Variable Declaration: Syntax and Scope

python variable declaration: Understand Python variable declaration: dynamic typing, type hints, scope, and best practices for clean, maintainable code.

PythonType HintsVariable ScopeDynamic Typing