In general the signature of a function is defined by the number and type of input arguments the function takes and the type of the result the function returns.

As an example in C++ consider the following function:

Copyint multiply(int x, int y){
    return x*y;
}

The signature of that function, described in an abstract way would be the set {int, int, int}.

As Python is a weakly typed language in general the signature is only given by the amount of parameters. But in newer Python versions type hints were introduced which clarify the signature:

Copydef multiply(x: int, y: int) -> int:
    return x*y
Answer from dreichler on Stack Overflow
🌐
Python
docs.python.org › 3 › library › inspect.html
inspect — Inspect live objects
The optional return_annotation argument can be an arbitrary Python object. It represents the “return” annotation of the callable. Signature objects are immutable.
Discussions

Documenting `__signature__`? - Documentation - Discussions on Python.org
The __signature__ attribute is an override for the inspect.signature function, which returns the value of that attribute if present instead of computing it. That behavior is not documented as part of the inspect.signature doc, but it is alluded to in inspect.unwrap, and it is described in the ... More on discuss.python.org
🌐 discuss.python.org
2
October 11, 2023
Using / and * in Python function signatures
Personally, I use keyword only when the parameter in question is "special" in some way and I want the usage more clear and also give me headroom to change the API later. Consider something like this: def create_pdf_report(foo, bar, *, debug=False) -> bytes Here, foo and bar are some parameters that will be used in the created PDF report, while the debug flag will cause a special PDF to be created which contains debug information (layout lines being drawn, boxes around paragraphs etc.) First, I don't want people to call the function as create_pdf_report(some_data, some_more_data, True) because it's not clear what Truemeans in this case, you'd have to check the signature of the create_pdf_report function to figure out it turns on debugging. create_pdf_report(some_data, some_more_data, debug=True) makes it obvious, even to someone not familiar with the API, that this is a report with some debugging info which should probably not make it into production. Another advantage is that in the future, if the API ever needs to change and a third parameter is added: create_pdf_report(foo, bar, baz, *, debug=True), old code will definitely raise an exception, while without keyword-only, create_pdf_report(data, more_data, True) will not, especially not if baz happens to be a boolean parameter. I've never used positional-only args. I know what they are for, I just never felt it necessary. More on reddit.com
🌐 r/learnpython
4
1
August 2, 2024
Helping people understand function signature syntax - Documentation - Discussions on Python.org
(Bringing a conversation about how to explain slash and star in function signatures from another post which talked about using tags, and a GitHub issue which experimented with tabs to show simplified vs complete signatures). Another possibility is to add a “help” icon next to signatures. More on discuss.python.org
🌐 discuss.python.org
9
July 20, 2024
What is the significance of a single, lone asterisk in a functions documentation?
Hello all, I keep coming across this and my Google Fu (actually DuckDuckGo Judo) cannot find the answer; what is the significance of a single, lone asterisk in the local parameter list of a functions documentation? For example… os.mkdir(path, mode=0o777, *, dir_fd=None) …to be clear I’m ... More on discuss.python.org
🌐 discuss.python.org
8
0
September 21, 2022
🌐
Python
peps.python.org › pep-0362
PEP 362 – Function Signature Object | peps.python.org
August 21, 2006 - The new metadata object is intended solely to make function introspection easier for Python programmers. A Signature object represents the call signature of a function and its return annotation.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-get-function-signature
Get Function Signature - Python - GeeksforGeeks
July 15, 2025 - A function signature in Python defines the name of the function, its parameters, their data types , default values and the return type. It acts as a blueprint for the function, showing how it should be called and what values it requires.
🌐
Readthedocs
python-forge.readthedocs.io › en › latest › signature.html
Signatures, parameters and return types — forge 18.6.0 documentation
Python callables have a signature: the interface which describes what arguments are accepted and (optionally) what kind of value is returned.
🌐
Chipx86
chipx86.blog › 2025 › 07 › 12 › a-crash-course-on-python-function-signatures-and-typing
A crash course on Python function signatures and typing
August 8, 2025 - Python’s inspect module is full of goodies for analyzing objects and code, and today we’ll explore the inspect.signature() function.
Find elsewhere
🌐
Python.org
discuss.python.org › documentation
Documenting `__signature__`? - Documentation - Discussions on Python.org
October 11, 2023 - The __signature__ attribute is an override for the inspect.signature function, which returns the value of that attribute if present instead of computing it. That behavior is not documented as part of the inspect.signature doc, but it is alluded to in inspect.unwrap, and it is described in the ...
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.5 documentation
February 27, 2026 - This use case is unique to Python and is not found in statically compiled languages or languages that only support single inheritance. This makes it possible to implement “diamond diagrams” where multiple base classes implement the same method. Good design dictates that such implementations have the same calling signature in every case (because the order of calls is determined at runtime, because that order adapts to changes in the class hierarchy, and because that order can include sibling classes that are unknown prior to runtime).
🌐
Real Python
realpython.com › ref › stdlib › inspect
inspect | Python Standard Library – Real Python
>>> def example_function(a, b=2, *args, **kwargs): ... pass ... >>> inspect.signature(example_function) <Signature (a, b=2, *args, **kwargs)>
🌐
Reddit
reddit.com › r/learnpython › using / and * in python function signatures
r/learnpython on Reddit: Using / and * in Python function signatures
August 2, 2024 -

Hi everyone,

I've been exploring the use of / and * in Python function signatures to specify positional-only and keyword-only arguments. I understand the syntax, but I'm curious about their practical implications and best practices. I am coding for more than two years now and have never used them myself and i see them really rarely. That's why would like to learn about others experiance and maybe get some advice when it is appropriate to use them in my own functions?

Looking forward to your insights! Thanks!

Top answer
1 of 2
5
Personally, I use keyword only when the parameter in question is "special" in some way and I want the usage more clear and also give me headroom to change the API later. Consider something like this: def create_pdf_report(foo, bar, *, debug=False) -> bytes Here, foo and bar are some parameters that will be used in the created PDF report, while the debug flag will cause a special PDF to be created which contains debug information (layout lines being drawn, boxes around paragraphs etc.) First, I don't want people to call the function as create_pdf_report(some_data, some_more_data, True) because it's not clear what Truemeans in this case, you'd have to check the signature of the create_pdf_report function to figure out it turns on debugging. create_pdf_report(some_data, some_more_data, debug=True) makes it obvious, even to someone not familiar with the API, that this is a report with some debugging info which should probably not make it into production. Another advantage is that in the future, if the API ever needs to change and a third parameter is added: create_pdf_report(foo, bar, baz, *, debug=True), old code will definitely raise an exception, while without keyword-only, create_pdf_report(data, more_data, True) will not, especially not if baz happens to be a boolean parameter. I've never used positional-only args. I know what they are for, I just never felt it necessary.
2 of 2
2
From a module standpoint (disclaimer: I have no experience writing modules - this is mostly speculation and regurgitation from memory), it's useful for providing a consistent API. Positional-only is useful for defining an interface when the library is written in C or similar (or even if you've just picked parameter names that might change). I believe that Python functions written in C can only accept positional arguments (I think PEP 570 explains it well). Keyword-only can make modules more flexible for backwards compatibility. By ensuring that arguments can only be passed by name, it makes the interface consistent (otherwise you've got two options for calling) and probably makes it easier to add or deprecate arguments
🌐
Python.org
discuss.python.org › documentation
Helping people understand function signature syntax - Documentation - Discussions on Python.org
July 20, 2024 - (Bringing a conversation about how to explain slash and star in function signatures from another post which talked about using <abbr> tags, and a GitHub issue which experimented with tabs to show simplified vs complete s…
🌐
IPython
ipython.org › ipython-doc › 3 › api › generated › IPython.utils.signatures.html
Module: utils.signatures — IPython 3.2.1 documentation
Function signature objects for callables. Back port of Python 3.3’s function signature tools from the inspect module, modified to be compatible with Python 2.7 and 3.2+.
🌐
AskPython
askpython.com › home › understanding and utilizing function signatures in python
Understanding and Utilizing Function Signatures in Python - AskPython
June 30, 2023 - In Python, a function signature provides crucial information about the types of parameters that a function can accept and the type of data it returns. The signature() function from the inspect module is used to determine the function signature, ...
🌐
TutorialsPoint
tutorialspoint.com › python-get-function-signature
Python - Get Function Signature
July 18, 2023 - The inspect.signature() method provides comprehensive access to function parameter details including annotations, default values, and parameter kinds ?
🌐
Python.org
discuss.python.org › python help
What is the significance of a single, lone asterisk in a functions documentation? - Python Help - Discussions on Python.org
September 21, 2022 - Hello all, I keep coming across this and my Google Fu (actually DuckDuckGo Judo) cannot find the answer; what is the significance of a single, lone asterisk in the local parameter list of a functions documentation? For example… os.mkdir(path, mode=0o777, *, dir_fd=None) …to be clear I’m ...
🌐
Real Python
realpython.com › python-asterisk-and-slash-special-parameters
What Are Python Asterisk and Slash Special Parameters For? – Real Python
October 21, 2023 - Whenever you think of Python’s asterisk operator (*), you most likely think of multiplication or exponentiation. Similarly, you probably associate the forward slash operator (/) with division. But you can also use the bare asterisk and slash as special parameters in function headers.
🌐
Pyo3
pyo3.rs › v0.22.3 › function › signature
Function signatures - PyO3 user guide
Like Python, by default PyO3 accepts all arguments as either positional or keyword arguments. Most arguments are required by default, except for trailing Option<_> arguments, which are implicitly given a default of None. This behaviour can be configured by the #[pyo3(signature = (...))] option which allows writing a signature in Python syntax.
🌐
GitHub
github.com › python › mypy › issues › 1927
Making a decorator which preserves function signature · Issue #1927 · python/mypy
July 22, 2016 - Currently this is how I annotate decorators which don't modify the function signature: from typing import Any, Callable, TypeVar FuncT = TypeVar('FuncT', bound=Callable[..., Any]) def print_on_call(func: FuncT) -> FuncT: def wrapped(*arg...
Author   sharmaeklavya2
🌐
Python.org
discuss.python.org › core development
Signatures, a call to action - Core Development - Discussions on Python.org
February 6, 2023 - I saw the other thread on math.log() and wanted to start a new one to shift the focus to what I think is the underlying problem than needs to be solved. If the playful story telling style doesn’t fit your tastes, pleas…