Purpose of calling function without brackets python

后端 未结 6 553
独厮守ぢ
独厮守ぢ 2020-11-27 16:07

Consider the following:

class objectTest():

    def __init__(self, a):
        self.value = a

    def get_value(self):
        return self.value

class exec         


        
6条回答
  •  忘掉有多难
    2020-11-27 16:34

    def mul(a, b):
        return a * b
    
    def add(a, b):
        return a + b
    
    def do(op, a, b):
        return op(a, b)
    
    do(add, 2, 3)  # return 5
    

提交回复
热议问题