Browse by Topic

Popular

Latest

Latest Python Posts

Illustration showing Python function parameters receiving values in order, with numbered positions mapping to arguments
Python

Python Positional Arguments: Order and Binding Rules

Learn how Python positional arguments bind by order, how to mix them with keyword arguments, and how *args or positional-only parameters create clearer APIs.

python functionsfunction argumentskeyword argumentsargs
Illustration showing named parameters flowing into a Python function container
Python

How Python Keyword Arguments Work

Learn how Python keyword arguments work, including keyword-only and positional-only parameters, **kwargs, ordering rules, and API design guidelines.

pythonkeyword-argumentsfunction-parametersapi-design
Illustration of a Python function definition with a mutable default list causing shared state across calls.
Python

Python Default Arguments: Mutable Pitfalls

Understand why Python evaluates default arguments once, how mutable defaults cause shared-state bugs, and how to use the None sentinel pattern.

pythondefault-argumentsmutable-defaultsfunction-definition
Illustration of Python default parameter evaluation showing a list being shared across function calls.
Python

Python Default Parameters: Avoiding Mutable Defaults

python default parameters: Understand how Python evaluates default parameters at definition time and why mutable defaults cause shared state. Learn the None sentinel p...

pythonfunction argumentsmutable defaultcode quality
Illustration of a Python function returning multiple values as a tuple being unpacked into separate variables.
Python

How to Return Multiple Values from a Python Function

Learn practical ways to return multiple values from a Python function: tuples, dictionaries, namedtuples, and dataclasses, with guidance on when each one is the best choice.

pythontuple unpackingnamedtupledataclass
Diagram showing a Python function returning a value to its caller, with tuple and None as alternative outputs
Python

Python Return Values: Syntax, Behavior, and Pitfalls

Understand Python return values: return syntax, implicit None, tuple unpacking, type hints, generator alternatives, and finally-block edge cases.

return statementtype hintstuple unpackinggenerators
Illustration of a Python function returning a value, showing the return statement directing a result out of a function block.
Python

Understanding the Python Return Statement

Learn how Python's return statement works: syntax, multiple values, implicit None, early exits, and differences from yield.

return syntaxfunction designgeneratorsmultiple return values
A diagram showing a Python function definition with parameters on the left and a function call with arguments on the right, connected by an arrow.
Python

Python Parameter vs Argument: The Real Difference

Learn the precise difference between parameters and arguments in Python, how they interact, and why the distinction improves code clarity.

Python FunctionsFunction ArgumentsParameter PassingPython Syntax
Illustration of Python function arguments with parameters and values
Python

Python Function Arguments: Syntax, Defaults, and *args/**kwargs

python function arguments: Learn how Python function arguments work: positional, keyword, default, *args, and **kwargs, with practical examples and common pitfalls.

pythonfunction-argumentskwargsargs
Illustration of Python function parameters showing positional, keyword, default, and variable-length arguments.
Python

Python Function Parameters: Syntax and Usage

Learn how Python function parameters work: positional, keyword, default, *args, **kwargs, and ordering rules for clean, maintainable function signatures.

python functionsfunction argumentskeyword argumentsdefault parameters