python get number of arguments of a function

Solutions on MaxInterview for python get number of arguments of a function by the best coders in the world

showing results for - "python get number of arguments of a function"
Alex
20 Jan 2020
1from inspect import signature
2
3def someMethod(self, arg1, kwarg1=None):
4    pass
5
6sig = signature(someMethod)
7print(len(params))  # 3
8