From: Arthur <aj...@ix...> - 2002-10-04 22:04:25
|
I feared in the back of my mind, my answer posted this morning is dead wrong. My answer had assumed that ball.pos could be treated as a normal Python list Which is not the case. It is of type "vector", which is not a native Python type, but one coming over from the cvisual code. As such it turns out it is neither sliceable or copyable. The *right* answer here seems to be: rinitial=list(ball.pos) or rinitial=tuple(ball.pos) This stores rinital in a separate object not effected by changes in ball.pos, but which can work for ball.pos=rinital should one want to restore the initial position of ball. I think. Sorry for the misinfo. Art >I think it worth supplementing Bruce's analysis with the solution to what was trying to be accomplished by >rininitial = ball.pos >I believe either: >rinitial = ball.pos[:] >or >rinitial =copy(ball.pos) >would get one to where one is trying to go. >[:] returns a complete "slice" of the list. >copy, of course, a copy of the list. >In either case rinitial is no longer an additional name for ball.pos, but an >object independant of it, which will not be modified upon the modification >of ball.pos. >I think I have this right. Corrections welcome. >Art |