python __call__

https://www.daniweb.com/programming/software-development/threads/39004/what-does-call-method-do

call( self[, args...])
Called when the instance is ``called'' as a function; if this method is defined, x(arg1, arg2, ...) is a shorthand for x.call(arg1, arg2, ...).

So ...

In [35]: class A:
....: def init(self):
....: print "init"
....: def call(self):
....: print "call"
....:
In [36]: a = A()
init
In [37]: a()
call

你可能感兴趣的:(python __call__)