__call__ 函数简单用法
PI = 3.14 class Circ(object): def __init__(self): pass def __call__(self, r): return r * r * PI c = Circ() print c(2) #12.56
把对象当作函数来用,相当于重载括号运算符
PI = 3.14 class Circ(object): def __init__(self): pass def __call__(self, r): return r * r * PI c = Circ() print c(2) #12.56
把对象当作函数来用,相当于重载括号运算符