- #1
stargazer3
- 44
- 3
I feel very stupid right now. Should be an easy question, but I googled it to no avail.
Basically, I have an class.object in my code which should be managed by a class.function
For example, I want the following code:
to return "0 1 2", instead of "0 0 1"
Can it be done in Python? If yes, what is the Python way of doing so? If no, why not?
Basically, I have an class.object in my code which should be managed by a class.function
For example, I want the following code:
Code:
class Z:
a=0
def mod(self):
self.a=self.a+1
t=Z
print Z.a
t.mod
print Z.a
t.a+=1
print Z.a
to return "0 1 2", instead of "0 0 1"
Can it be done in Python? If yes, what is the Python way of doing so? If no, why not?
Last edited: