I am new to python.I was doing following code and I met an undesired outcome. Please look onto my code and let me know what am I doing wrong:
class TestClass(object):
@classmethod
def __init__(self, val):
self.val = val
@classmethod
def value(self):
return self.val
def Test():
a = TestClass(9)
b = TestClass(8)
c = TestClass(7)
print(a.value(), b.value(), c.value())
expecting output as
9 8 7
but getting output as
7 7 7
what is wrong with my code.
__init__is a@classmethod???value, sincevalis now bound to the instance