Quote:
Originally Posted by unluckyboy
lol that is frustrating. i just made duplicate variable this time around
all_data2 = all_data
then when i screwed up the all_data variable it automatically screwed up all_data2 in an identical manner. didnt see that coming
Python variables are references to data structures so setting b=a below just creates a new label for "a" rather than copying a:
Code:
a = [1, 2, 3]
b = a
b.append(4)
print b # outputs 1, 2, 3, 4
print a # outputs 1, 2, 3, 4
print a is b # prints True
if you want to get a copy of a list you can do:
Code:
a = [1, 2, 3]
b = [x for x in a]
b.append(4)
print b # outputs 1, 2, 3, 4
print a # # outputs 1, 2, 3
print a is b # outputs False