a=5
x="hi"
my_list=['One','Two','Three']
print(callable(a)) # False
print(callable(x)) # False
print(callable(my_list)) # False
All above objects are not Callable.
Using Class and Objects
class student_kit():
#instance attributes
def __init__(self,name):
self.name= name
Alex=student_kit('Alex') # object declaration
print(callable(student_kit)) # True
print(callable(Alex)) # False , object is not callable
#Alex() # this will generate error
The last line will generate error like this.
TypeError: 'student_kit' object is not callable
The class student_kit is callable, the object Alex is not callable.
def my_function():
print("Hello")
print(callable(my_function)) # Output: True
x = 5
print(callable(x)) # Output: False
class MyClass:
def method(self):
print("This is a method.")
obj = MyClass()
print(callable(obj.method)) # Output: True
print(callable(obj)) # Output: False
class CallableClass:
def __call__(self):
print("This class instance is callable.")
obj = CallableClass()
print(callable(obj)) # Output: True
string = "Hello"
print(callable(string)) # Output: False
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.