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 :: python code to add element in list 
Python :: remove element from a list python 
Python :: discord.py get client avatar 
Python :: numpy array into tuple 
Python :: how to add number in tuple 
Python :: python csv to excel 
Python :: syntax of ternary operator 
Python :: pythonanywhere django 
Python :: python string equals 
Python :: print column name and index python 
Python :: heroku procfile 
Python :: infinity range or infinity looping 
Python :: get center position of countries geopandas 
Python :: names of all methods in class introspect pythonm 
Python :: randint without repitition 
Python :: python str and repr 
Python :: Python - Comment supprimer Commas de la corde 
Python :: python how to extend a class 
Python :: ex:deleate account 
Python :: django query multiple 
Python :: Define the learnable resizer utilities 
Python :: Update only keys in python 
Python :: loosen_pickle 
Python :: ploting bargraph with value_counts(with title x and y label and name angle) 
Python :: def get_context_data(self, **kwargs): 
Python :: install first person controller python 
Python :: series clip 
Python :: supervisor gunicorn virtualenv flask 
Python :: islink(node1 node2) is used for 
Python :: get queryset 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =