TypeError: 'int' object is not callable error appears

Asked 2 years ago, Updated 2 years ago, 80 views

defk(T, n): #rate constants
    if n == 1:
        return Kb * T / h * np.exp(-gibbs / (R * T))
    elif n == 2:
        return Kb * T / h * np.exp(-gibbs1 / (R * T))

def ktot(T, n): # Total rate constant
    _t = 0.0
    for m in range(n):
        _t += k(T, m + 1)
    return _t

I squeezed it like above, but it came out as below

Traceback (most recent call last):
  File "C:\Users\1\Desktop\University\Python\main.py", line 259, in <module>
    _time += -1 * np.log(r) / ktot(T2, 2) #t value cumulative increase
  File "C:\Users\1\Desktop\University\Python\main.py", line 52, in ktot
    _t += k(T, m + 1)
TypeError: 'int' object is not callable

typeerror int object callable

2022-09-20 15:08

1 Answers

The error [__] object is not callable is an error that occurs when you write something like a function, not a function.

In the question, the 'int' object is not callable error occurred for k(T, m+1), which means that k is a variable of type int rather than a function. Perhaps an integer variable called k is used in the middle of the code, so the function defined by defk(...) is obscured (called shadowing).


2022-09-20 15:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.