Is there a generic way for a function to reference itself?

后端 未结 4 942
粉色の甜心
粉色の甜心 2020-12-03 00:50

I can access a python function\'s attribute inside of function itself by below code:

def aa():
    print aa.__name__
    print aa.__hash__
    # other simlia         


        
4条回答
  •  甜味超标
    2020-12-03 01:22

    You can at least say self = bb in the first line, and then you only need to change that line when you change the function name, instead of every other reference.

    My code editor highlights the variable self the same way it does for classes, too.

提交回复
热议问题