Detecting empty function definitions in python

后端 未结 4 775
野的像风
野的像风 2021-02-20 01:37

I need to detect whether a function is an empty definition or not. It can be like:

def foo():
    pass

or like:

def foo(i, *arg         


        
4条回答
  •  [愿得一人]
    2021-02-20 02:05

    The way you're using works. A perhaps more "elegant" solution would be to have a list of functions, and in all your empty (or all your non-empty) functions you would add it to the list, and then check whether the function is in the list or not.

提交回复
热议问题