美文网首页
python __call__

python __call__

作者: 橙姜 | 来源:发表于2018-03-01 17:04 被阅读0次

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__

      本文链接:https://www.haomeiwen.com/subject/wkcnxftx.html