Last modified: Apr 25, 2026 By Alexander Williams
Fix TypeError: 'NoneType' Object Not Callable
You write Python code, run it, and see a red error: TypeError: 'NoneType' object is not callable. This error confuses many beginners. It means you tried to call something as a function, but that something is None. In Python, only functions and classes are callable. None is not callable.
This article explains the common causes of this error. You will learn how to spot the problem and fix it quickly. We use short examples and clear code. By the end, you will handle this error with confidence.
What Does the Error Mean?
Python uses parentheses () to call a function. When you write my_function(), Python expects my_function to be a callable object. If my_function is None, you get the 'NoneType' object is not callable error.
This error often happens when you assign a function result to a variable with the same name as the function. For example:
# Example 1: Overwriting a function with its return value
def get_data():
return "some data"
get_data = get_data() # Now get_data is a string, not a function
print(get_data()) # Error: 'str' object is not callable
In this code, get_data becomes a string. Calling it with parentheses fails. If the function returned None, you would see the NoneType error.
Common Cause: Function Returns None
Many functions return None by default. A function without a return statement returns None. If you assign that result to a variable and then try to call it, you get the error.
Look at this example:
# Example 2: Function without return
def do_nothing():
pass # No return statement
result = do_nothing() # result is None
result() # TypeError: 'NoneType' object is not callable
The function do_nothing returns None. The variable result becomes None. Calling result() triggers the error.
To fix this, ensure every function returns a value if you plan to call it later. Or, use a different variable name for the result.
Common Cause: Overwriting a Built-in Function
Python has many built-in functions like print, input, and len. If you accidentally assign a value to the same name, you lose the original function. Then calling it later gives the error.
# Example 3: Overwriting the print function
print = None # Now print is None
print("Hello") # TypeError: 'NoneType' object is not callable
This error is easy to fix. Do not use built-in names for your variables. If you already did, restart your Python interpreter or use del print to remove the variable.
Common Cause: Missing Parentheses in Method Calls
When you call a method on an object, you must use parentheses. Forgetting them returns the method object itself, not the result. If you then try to call that method object with extra parentheses, you might get this error.
# Example 4: Missing parentheses
my_list = [1, 2, 3]
append_method = my_list.append # This is the method object, not called
append_method(4) # Works fine
print(my_list) # Output: [1, 2, 3, 4]
# Now the tricky part:
result = my_list.sort # Forgot parentheses
print(result()) # TypeError: 'NoneType' object is not callable
The sort method returns None and sorts the list in place. result becomes None. Calling result() fails. Always use parentheses to call methods.
How to Debug the Error
When you see this error, look at the line number in the traceback. Check which variable you are calling. Use print(type(variable)) to see its type. If it shows <class 'NoneType'>, you found the problem.
Another tip: use a debugger or add print statements before the error line. This helps you see the value of the variable you are calling.
For more details on common Python errors, read our guide on Python TypeError: Causes and Fixes. It covers similar issues like TypeError: 'int' object is not callable.
Best Practices to Avoid the Error
Follow these simple rules to prevent the 'NoneType' object is not callable error:
- Never use the same name for a function and its return value.
- Always use parentheses when calling functions and methods.
- Check that functions return the expected type, not
None. - Avoid overwriting built-in Python functions like
printorlen.
If you are working with functions that modify data in place (like list.sort() or list.reverse()), remember they return None. Do not assign their result to a variable and try to call it.
Understanding these patterns will save you time. Our article on Python TypeError: Causes and Fixes has more examples and common fixes for similar errors.
Real-World Example and Fix
Consider a function that reads a file and returns its content. If the file does not exist, the function might return None. Then you try to call that None value.
# Example 5: Real-world scenario
def read_file(filename):
try:
with open(filename, 'r') as f:
return f.read()
except FileNotFoundError:
return None # Returns None if file missing
content = read_file("missing.txt")
print(content()) # Error: 'NoneType' object is not callable
Fix: check if content is None before calling it. Or, have the function raise an exception instead of returning None.
# Fixed version
content = read_file("missing.txt")
if content is not None:
print(content) # No parentheses needed, content is a string
else:
print("File not found")
This fix removes the callable error. You treat content as data, not a function.
Conclusion
The TypeError: 'NoneType' object is not callable error happens when you try to call None as a function. The main causes are overwriting a function name with its return value, forgetting to return a value, or misusing built-in functions. Debug by checking the variable type with print(type()). Fix by using distinct variable names and always calling functions with parentheses. With these tips, you can solve this error quickly and write cleaner Python code.
For a deeper dive into Python errors, including this one, check our article on Python TypeError: Causes and Fixes. It explains multiple type errors and how to handle them.