There also inspect module that is a little more robust,as it will give all info also about default arguments and keyword arguments.
def foo(arg, new='snake', **kwargs): return f'python-forum {arg} a {new}? no {kwargs}'Test:
>>> import inspect >>> >>> foo.__code__.co_varnames[:foo.__code__.co_argcount] ('arg', 'new') >>> >>> inspect.signature(foo) <Signature (arg, new='snake', **kwargs)> >>> >>> foo('io', python='forum') "python-forum io a snake? no {'python': 'forum'}"