'int' Object Is Not Callable Error Python
Hey guys so I am getting this 'TypeError: 'int' object is not callable' error when I run this code, I did some research and I think it's something with my variable naming? Could so
Solution 1:
You are masking your method balance
with a instance attribute balance
. Rename one or the other. You could rename the instance attribute by pre-pending it with an underscore for example:
defset(self, bal):
self._balance = bal
defbalance(self):
returnself._balance
Attributes on the instance trump those on the class (except for data descriptors; think property
s). From the Class definitions documentation:
Variables defined in the class definition are class attributes; they are shared by instances. Instance attributes can be set in a method with
self.name = value
. Both class and instance attributes are accessible through the notation “self.name
”, and an instance attribute hides a class attribute with the same name when accessed in this way.
Post a Comment for "'int' Object Is Not Callable Error Python"