The following example, when executed, returns:
Traceback (most recent call last):
File "/home/des/programming/python/OOP/test.py", line 13, in ?
TypeError: 'int' object is not callable
class demonstration: def __init__(self,number): self.number = number def number(self): fiveup = self.number + 5 print fiveup demonstration(6).number()
Now, I know how to fix the problem, don't let variables and methods share names.
But I want to know why it does happen. I guess because the method (number) is in fact demonstrtaion.self.number() or something like it. Because the names conflict. But I'm too much of a newb to actually know. Any answers?