Python Fankid
Wednesday, October 25, 2017
Today in things I didn't know about Python - __call__
If you define a __call__ method in your class it will get called when you call an instance of that class. I didn't know that. That is all.
In [336]: class foo:
def __init__(self):
print "in init"
def __call__(self):
print "in call"
In [337]: bar = foo()
in init
In [338]: bar()
in call
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)