Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

__call__ python

#this will allow you to treat object as function
class Test:
  def __init__(self, num):
    self.num = num
  def __call__(self, inp):
    print(self.num*inp)

#create an instance of Test class
obj = Test(5)
obj(3) #15
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
1+9 =