Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

__call__ python


def add(a,b):
    return a + b

Comment

__call__() python

class Foo:
    def __call__(self, a, b, c):
        # ...

x = Foo()
x(1, 2, 3) # __call__
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib cheatsheet 
Python :: what value do we get from NULL database python 
Python :: django group by 
Python :: random question generator python 
Python :: python check if all caps 
Python :: how to get input python 
Python :: python function as parameter 
Python :: get mac address python 
Python :: python how to convert csv to array 
Python :: randomforestregressor in sklearn 
Python :: python array to string 
Python :: datetime to int in pandas 
Python :: pip install for python 2 and python3 
Python :: how to get user id from username discord.py 
Python :: slicing string in python 
Python :: how to take input complex number in python 
Python :: python numpy vstack 
Python :: sqlite query in python 
Python :: convert price to float python 
Python :: dynamic array python numpy 
Python :: how to export DataFrame to CSV file 
Python :: sort list alphabetically python 
Python :: python find intersection of two lists 
Python :: how to calculate the sum of a list in python 
Python :: scikit image 0.16.2 
Python :: data frame list value change to string 
Python :: train split 
Python :: LoginRequiredMixin 
Python :: python how to count number of true 
Python :: how to check if a input is an integer python 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =