FMeinicke's Wiki

Home

❯

Coding

❯

Python

❯

Get the number of parameters for a function

Get the number of parameters for a function

May 26, 20251 min read

  • python/inspect/signature

signature

Source

  • https://stackoverflow.com/a/41188411/12780516
from inspect import signature
 
def some_func(a, b, c) -> None:
    pass
 
params = signature(some_func).parameters
num_params = len(params)

Graph View

Created with Quartz v4.5.0 © 2025

  • GitHub