My question is why I can't call the function again? Or, how to make that?
Suppose I have this function:
def a(x, y, z):
if x:
return y
else:
return z
and I call it with:
print a(3>2, 4, 5)
I get 4.
But imagine that I declare a variable with the same name that the function (by mistake):
a=2
Now, if I try to do:
a=a(3>4, 4, 5)
or:
a(3>4, 4, 5)
I will get this error: "TypeError: 'int' object is not callable"
It's not possible to assign the variable 'a' to the function?
解决方案
After you do this:
a = 2
a is no longer a function, it's just an integer (you reassigned it!). So naturally the interpreter will complain if you try to invoke it as if it were a function, because you're doing this:
2()
=> TypeError: 'int' object is not callable
Bottom line: you can't have two things simultaneously with the same name, be it a function, an integer, or any other object in Python. Just use a different name.