Find functions explicitly defined in a module (python)

后端 未结 5 2000
北恋
北恋 2020-12-03 04:48

Ok I know you can use the dir() method to list everything in a module, but is there any way to see only the functions that are defined in that module? For example, assume m

5条回答
  •  -上瘾入骨i
    2020-12-03 05:29

    the python inspect module is probably what you're looking for here.

    import inspect
    if inspect.ismethod(methodInQuestion):
        pass # It's a method
    

提交回复
热议问题