In recent versions you can define functions arguments multiple ways. Here is how they can be defined and called:

Copydef fun(a, b, c='foo'):
    ...
fun(1, 2)
fun(1, 2, 'bar')
fun(1, b=2)
fun(1, b=2, c='bar')
fun(a=1, b=2, c='bar')

where a and b are positional or keyword args and c is an optional positional or keyword arg

or

Copydef fun(a, b, *, c, d='foo'):
    ...
fun(1, 2, c='bar')
fun(1, b=2, c='bar', d='baz')
fun(a=1, b=2, c='bar', d='baz')

where a and b are positional or keyword args and c is a mandatory kwarg and d is an optional kwarg

or

Copydef fun(a, b, /, c, *, d, e='foo'):
    ...
fun(1, 2, 3)
fun(1, 2, c=3)
fun(1, 2, c=3, d='bar')

where a and b are positional only args, c is a positional or keyword arg and d is a mandatory kwarg and e is an optional kwarg

Answer from DevLounge on Stack Overflow
🌐
Real Python
realpython.com › python-optional-arguments
Using Python Optional Arguments When Defining Functions – Real Python
October 27, 2025 - File "optional_params.py", line ... parameter with a default · The parameters with no default value must always come before those that have a default value....
Discussions

python - How do I define a function with optional arguments? - Stack Overflow
To get a better sense of what's ... various options: positional-or-keyword (arg or arg="default_value"), positional-only (before /, in the parameter list), keyword-only (after *, in the parameter list), var-positional (typically *args) or var-keyword (typically **kwargs). See the Python documentation ... More on stackoverflow.com
🌐 stackoverflow.com
Pydantic: Difference between typing.Optional and default value
Using typing.Optional just makes it more clear and explicit that the parameter is optional. Its still setting a default value of None, but the Optional type hint just lets you know that leaving the value as None is completely fine. Its similar to using Union[int, None] as the type. The value can either be an int type or a None type. The default value approach you included has a default value of None, but its not a clear whether that parameter is truly optional, or is just using None as the default value, but the value should be set to an int and not left as None. More on reddit.com
🌐 r/learnpython
2
27
October 31, 2021
Function argument with a default value is not like Optional
Why a function default argument is not a syntactic sugar for Optional so one can programmatically pass None to get the default value ? Because that's how it was designed. What, exactly, are you looking for here? How should we do wrappers functions without copying the default values of the wrapped function ? args / kwargs More on reddit.com
🌐 r/learnpython
50
6
July 18, 2025
Adding optional arguments to a function
Type hints are ignored by the interpreter. You still need to provide a default value for the argument if one isn't provided in the function call. The appropriate default value to use with the Optional type hint is None, so: def function( data1: list, data2: list, opt1: Optional[list] = None, new: Optional[dict] = None, ) More on reddit.com
🌐 r/learnpython
2
1
September 8, 2021
🌐
Python.org
discuss.python.org › core development
Should `None` defaults for optional arguments be discouraged? - Core Development - Discussions on Python.org
February 5, 2023 - I recently merged a PR authored by Sergey Kirpichev that fixes inspect.signature (which previously failed with a ValueError) for math.log and cmath.log. A side-effect of that change is that math.log and cmath.log now accept the Python value None for the base argument.
🌐
Career Karma
careerkarma.com › blog › python › python optional arguments: a how-to guide
Python Optional Arguments: A How-To Guide | Career Karma
December 1, 2023 - Optional parameters must appear after required arguments when you define a function. Required arguments are those that do not have a default value assigned. Required arguments are often called “required positional arguments” because they ...
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › master python optional arguments usage [tutorial]
Master Python Optional Arguments Usage [Tutorial] | GoLinuxCloud
January 9, 2024 - Utilizing None as a default value in function parameters allows you to distinguish between a caller who has not provided a value for an argument and a caller who has explicitly provided a None value. This makes None a smart choice for default values in python optional arguments. ... When you want to make the argument optional without assuming any default behavior.
🌐
Mimo
mimo.org › glossary › python › optional-arguments
Python Optional Argument: Syntax, Usage, and Examples
You’ll see this a lot in a module ... functions for every variant. An optional argument in Python is a function argument backed by a default value, so the caller can skip it when they want the default behavior....
Find elsewhere
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › AdvancedFunctions › OptionalParameters.html
15.1. Introduction: Optional Parameters — Foundations of Python Programming
When the optional parameter is included, then the formal parameter is bound to the value provided. Optional parameters are convenient when a function is almost always used in a simple way, but it’s nice to allow it to be used in a more complex way, with non-default values specified for the optional parameters.
🌐
Index.dev
index.dev › blog › default-vs-optional-parameters-python
Default vs Optional Parameters in Python Functions: Key Differences
October 31, 2024 - While default parameters enable you to provide predefined values, optional parameters let you send a variable number of arguments to a function. Python has two strong mechanisms for managing optional parameters:
🌐
Index.dev
index.dev › blog › python-functions-optional-arguments
5 Ways to Define a Function with Python Optional Arguments
November 4, 2024 - It is preferable to avoid using mutable default parameters unless there is a compelling reason to do so. You may not know ahead of time how many arguments your function will get. In such instances, Python's · *args and **kwargs syntax let you ...
🌐
Medium
medium.com › @laurentkubaski › python-type-hints-how-many-ways-can-you-say-optional-a940f7ef03e2
Python Type Hints: How Many Ways Can You Say ‘Optional’? | by Laurent Kubaski | Medium
September 2, 2025 - def function(param: str) - The parameter must be a string (None is not allowed) - No default value: a value needs to be passed when calling the function. def function(param: str = None) -> INVALID - This is an invalid parameter definition because ...
🌐
Codecademy
codecademy.com › learn › learn-intermediate-python-3 › modules › int-python-function-arguments › cheatsheet
Learn Intermediate Python 3: Function Arguments Cheatsheet | Codecademy
If the function is invoked without a value for a specific argument, the default value will be used. ... In Python, a default parameter is defined with a fallback value as a default argument.
🌐
Linux Manual Page
linux.die.net › diveintopython › html › power_of_introspection › optional_arguments.html
4.2. Using Optional and Named Arguments
Python allows function arguments to have default values; if the function is called without the argument, the argument gets its default value. Futhermore, arguments can be specified in any order by using named arguments. Stored procedures in SQL Server Transact/SQL can do this, so if you're ...
🌐
Purple Engineer
purpletutor.com › home › understanding code › python optional parameters guide for better coding flexibility and readability
Python optional parameters explained with default values and examples
January 21, 2026 - Python optional parameters are function arguments assigned a default value, allowing you to call the function without providing a value for every parameter. This mechanism makes functions more flexible and your code cleaner, as it prevents errors ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-pass-optional-parameters-to-a-function-in-python
How to Pass Optional Parameters to a Function in Python - GeeksforGeeks
July 23, 2025 - This has certain advantages: The order of arguments does not need to be maintained. Only required parameters must be passed , optional ones can be omitted. The parameter names must match exactly as declared in the function.
🌐
iO Flood
ioflood.com › blog › python-optional-arguments
Python Optional Arguments | Guide (With Examples)
November 17, 2023 - In Python, you can assign a default value to a function argument. This makes the argument optional, because the function can be called without providing a value for this argument.
🌐
University of Toronto
teach.cs.toronto.edu › ~csc110y › fall › notes › 12-interlude-nifty-python-features › 03-functions-with-optional-parameters.html
12.3 Functions with Optional Parameters
Suppose we want to define a function that takes a number n and by default returns n + 1, but allows the caller to specify an optional step amount to increase by. def increment(n: int, step: int = 1) -> int: """Return n incremented by step. If the step argument is omitted, increment by 1 instead. """ return n + step · Let’s experiment with this function in the Python console: >>> increment(10, 2) # n = 10, step = 2 12 >>> increment(10) # n = 10 11 · In the latter case, no argument is passed for the step parameter, and so the default value 1 is used instead, causing 10 + 1 == 11 to be returned.
🌐
GeeksforGeeks
geeksforgeeks.org › default-arguments-in-python
Default arguments in Python - GeeksforGeeks
This allows users to call the function with or without those parameters, making the function more flexible. When an optional parameter is not provided, Python uses its default value.
Published   September 11, 2024