Python method retrieved with getattr() does not need `self` in call? Why Not?

后端 未结 0 1263
清歌不尽
清歌不尽 2020-12-31 19:28

The following code works:

class Foo:
    def run_this(self):
        print("ran this")

ff = Foo()
method = getattr(ff, "run_this")
method         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题