Why can't I call the function again? Or, how can I make it?
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"
Is it not possible to assign the variable 'a' to the function?
ato be anintinstead of afunction; Now,ais a variable (instead of a function); hence the consequenceself.a, but want to have a 'public' function calleda(units='g')that converts the units on the private variable 'a' to whatever the caller wants. Instead, I find I need to write my 'public' function asdef format_a(units='g'):def x(self): return self.x, you need to name the getter differently, e.g.get_x(self). I came here because after a refactoring of my getter name, a working code was just not working anymore.