R
Rodney Dunning
Hello,
I've just picked up python to create some 3D visuals (using VPython)
for a physics class I'm developing. While writing a program, I
developed a "bug" that is reflected in the code below. When executed,
*both* Test1 and Test2 are changed. Can someone explain this to me?
Why is Test2 changed?
from visual import *
from __future__ import division
##Variable tester
a = vector(1,0,0)
Test1 = a
Test2 = a
print "Test1 = ",Test1
print "Test2 = ",Test2
Test1.x += 3
print "Test1 = ",Test1
print "Test2 = ",Test2
##End code
I've programmed extensively in Fortran-90. Is there anything in python
analogous to the PARAMETER keyword in Fortran-90, such as
integer, PARAMETER :: i = 10 !*** the value of i cannot be changed,
period.
Thanks for your help.
I've just picked up python to create some 3D visuals (using VPython)
for a physics class I'm developing. While writing a program, I
developed a "bug" that is reflected in the code below. When executed,
*both* Test1 and Test2 are changed. Can someone explain this to me?
Why is Test2 changed?
from visual import *
from __future__ import division
##Variable tester
a = vector(1,0,0)
Test1 = a
Test2 = a
print "Test1 = ",Test1
print "Test2 = ",Test2
Test1.x += 3
print "Test1 = ",Test1
print "Test2 = ",Test2
##End code
I've programmed extensively in Fortran-90. Is there anything in python
analogous to the PARAMETER keyword in Fortran-90, such as
integer, PARAMETER :: i = 10 !*** the value of i cannot be changed,
period.
Thanks for your help.