有什么办法可以让局部变量从一等到二等?
class Position:
positionX = 0.0 #starting value of positionX, but I need to change this in counting method when I push arrow key
def counting(self, posX):
self.positionX = posX #posX is for example position X of my cursor which I move with arrows so value is changing when I push to arrow key.
class Draw:
posInst = Position()
print posInst.positionX #here I need to get positionX variable from Position class. But its show me just 0.0. I need to get exact value which is change when I push arrow key and its change in counting method. If I push arrow key and value in counting method will be 20 I need this number in Draw class. But everytime is there 0.0.
有什么办法可以做到这一点?感谢您的建议。