Object is not callable
This error occurs when you attempt to invoke a non-callable object (like a string, list, or integer) as if it were a function using parentheses.
Usually happens because:
- ☑ Shadowing built-in identifiers (list, dict, str, sum) with variable values
- ☑ Using parentheses () instead of brackets [] for sequence queries
- ☑ Omitted math multiplication signs (*) inside algebraic expressions
🔍 Quick Checklist:
What is Object is not callable?
The 'Object is not callable' error is raised by the 'TypeError' exception class when you append parentheses '()' to an object that does not implement the magic '__call__' method. This commonly happens because a variable name shadows a built-in function (e.g. naming a list 'list = []' and then trying to call the list constructor 'list()'), forgetting mathematical operators (like writing 'x(y + 1)' instead of 'x * (y + 1)'), or placing parentheses after properties instead of methods.
Common Causes
- Parentheses on non-callable variables: Attempting to call standard variables (strings, lists, dicts) as functions (e.g. 'name()').
- Shadowing built-in function names: Reassigning built-in function identifiers (like 'list', 'str', 'dict') to local variables.
- Missing math operator overrides: Writing math equations using algebraic shorthand formats without operators (e.g. '5(x + 2)').
| Cause | Frequency |
|---|---|
| Shadowing built-in constructors (e.g. list/str/dict variables) | ⭐⭐⭐⭐⭐ |
| Calling list index bracket queries using parentheses () | ⭐⭐⭐⭐ |
| Missing math multiplication operators (*) | ⭐⭐⭐ |
Common Mistakes
- Using parentheses `()` instead of square brackets `[]` when querying elements from a list, tuple, or dictionary.
- Declaring properties in custom classes with the same name as methods, leading attributes to shadow functions.
How to Fix
Python Operations & Verification
Do not override built-in function names (like list, dict, str, int, type, sum) with variable names.
# Wrong: shadows sum
# sum = 10
# values = [1, 2, 3]
# print(sum(values)) # TypeError: 'int' object is not callable
# Correct
total_sum = 10
values = [1, 2, 3]
print(sum(values)) # 6Platform Specific Fixes
Check built-in class types definitions in terminal prompts.
python3 -c "print(callable(int))"Best Practices
- Adopt descriptive naming structures (`user_list`, `total_sum`) to avoid clashes with built-ins.
- Verify syntax operators inside complex mathematical formulas.
Frequently Asked Questions (FAQ)
Q: What does 'Object is not callable' mean?
It means you added parentheses '()' after a variable that is not a function, class, or method, attempting to run it like one.
Q: How do I fix ''list' object is not callable'?
This usually happens if you named a local variable 'list' (e.g. 'list = [1, 2, 3]') which shadows the built-in 'list()' constructor. When you try to call 'list()' later, Python tries to call your local list variable and fails. Rename your variable to something else, like 'my_list'.
Q: Why did math equations throw this error?
In math, '5(x + 2)' implies multiplication. In Python, this is interpreted as calling a function named '5'. You must write: '5 * (x + 2)'.
Q: How do I check if an object is callable in Python?
Use the built-in 'callable(obj)' function. It returns 'True' if the object is a function or implements the '__call__' method, and 'False' otherwise.