Python has a set of built-in methods and
__call__ is one of them. The
__call__ method enables Python programmers to write classes where the instances behave like functions and can be called like a function. When the instance is called as a function; if this method is defined,
x(arg1, arg2, ...) is a shorthand for
x.__call__(arg1, arg2, ...).
object() is shorthand for object.__call__()
Instance Created Instance is called via special method
Instance Created 200
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Is Python call by reference or call by value
- How to Call a C function in Python
- Python - Call function from another function
- call() decorator in Python
- Python: Call Parent class method
- Python - Call function from another file
- Decorator to print Function call details in Python
- How to call C / C++ from Python?
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.