callable()

callable() checking object callable or not

Returns Booleans, True if callable , False otherwise.
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.

Example 1: Checking Callable Objects

def my_function():
    print("Hello")
print(callable(my_function))  # Output: True

Example 2: Callable vs Non-Callable Objects

x = 5
print(callable(x))  # Output: False

Example 3: Checking Callable Methods Inside a Class

class MyClass:
    def method(self):
        print("This is a method.")
        
obj = MyClass()
print(callable(obj.method))  # Output: True
print(callable(obj))         # Output: False

Example 4: Callable Classes

class CallableClass:
    def __call__(self):
        print("This class instance is callable.")
        
obj = CallableClass()
print(callable(obj))  # Output: True

Example 5: Non-Callable Built-in Objects

string = "Hello"
print(callable(string))  # Output: False

All Built in Functions in Python bytes()

Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate 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.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer