Find functions explicitly defined in a module (python)

后端 未结 5 2013
北恋
北恋 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条回答
  •  盖世英雄少女心
    2020-12-03 05:48

    You can check __module__ attribute of the function in question. I say "function" because a method belongs to a class usually ;-).

    BTW, a class actually also has __module__ attribute.

提交回复
热议问题