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

Illustration of Python function declaration showing def keyword and parameters.
Python

Python Function Declaration: Syntax and Parameters

Learn the syntax for declaring functions in Python, including parameters, return values, default arguments, *args/**kwargs, and type hints.

python functionsfunction syntaxparameterstype hints
Diagram showing a nested tuple structure being unpacked into separate variables in Python
Python

Python Nested Unpacking: Syntax and Patterns

Learn how to unpack nested tuples and lists in Python, use star expressions for variable-length data, and avoid common dictionary and string pitfalls.

unpackingtuple unpackingdestructuringpython syntax
Illustration of two variables exchanging values using Python tuple unpacking, with a clean and modern design.
Python

How to Swap Variables in Python Using Tuple Unpacking

Learn how to swap variables in Python using tuple unpacking, why the evaluation order matters, and how to avoid common mistakes.

tuple unpackingvariable swapmultiple assignmentPython syntax
Illustration of Python double-star unpacking passing a dictionary into a function's keyword arguments
Python

Python **kwargs Unpacking: Syntax, Usage, and Pitfalls

Learn how Python's **kwargs unpacking works in function definitions and calls, with practical examples and common mistakes to avoid.

pythonkwargsfunction argumentsdict unpacking
Diagram showing how *args collects multiple positional arguments into a tuple and how * unpacks a list into separate arguments.
Python

Python *args Unpacking: Syntax and Common Pitfalls

python *args unpacking: Learn how *args packs extra positional arguments and how * unpacks iterables into function calls, with practical examples and pitfalls.

pythonargsfunction argumentsunpacking
Illustration of Python starred expression unpacking a list into multiple variables and function arguments.
Python

Python Starred Expression: Unpacking and Expansion

python starred expression: Learn how Python starred expressions work in assignments, function calls, and definitions, with practical examples and common pitfalls.

Pythonunpacking*args**kwargs
Illustration of Python extended unpacking showing values being distributed from a list into multiple variables and function arguments.
Python

Python Extended Unpacking: Syntax and Practical Uses

Understand Python's extended unpacking syntax for assignments, function calls, and iterable handling, with practical examples and common pitfalls.

unpackingstar-expressionsargskwargs
Illustration of Python iterable unpacking showing multiple variables being assigned from a single list or tuple.
Python

Python Iterable Unpacking: Syntax and Pitfalls

Learn how Python iterable unpacking works: basic assignment, starred expressions, loops, function calls, dictionaries, and common pitfalls.

PythonIterablesTuple UnpackingStarred Expressions
Illustration of Python sequence unpacking showing a tuple split into multiple labeled variables
Python

Python Sequence Unpacking: Syntax and Common Pitfalls

Learn Python sequence unpacking: tuple and list unpacking, extended unpacking with *, nested patterns, and how to avoid ValueError.

sequence unpackingtuple unpackingextended unpackingpython syntax
Illustration showing Python unpacking of a tuple into separate variables using the asterisk operator.
Python

Python Unpacking: Syntax, Edge Cases, and Patterns

python unpacking: Understand Python unpacking: sequence assignment, starred expressions, dictionary unpacking, and function argument handling with practical examples.

pythonunpackingstarred-expressionsdictionary-unpacking