Is there a way to check a function's signature in Python?

后端 未结 4 2360
我寻月下人不归
我寻月下人不归 2021-02-19 08:16

I\'m looking for a way to check the number of arguments that a given function takes in Python. The purpose is to achieve a more robust method of patching my classes for tests.

4条回答
  •  执笔经年
    2021-02-19 08:31

    The inspect module allows you to examine a function's arguments. This has been asked a few times on Stack Overflow; try searching for some of those answers. For example:

    Getting method parameter names in python

提交回复
热议问题