I've read that python treats all variable assignments as references instead of copy. So the code below for generating 3 independent lists wouldn't work:
sizeNeeded = 4
itemDateNums = itemWeights = itemVolumes = [[]] * sizeNeeded
itemDateNums[1].append("hello world")
# All instances are now hello world because of referencing
So I rewrote the code:
sizeNeeded = 4
itemDateNums = []
itemWeights = []
itemVolumes = []
for shifts in range(sizeNeeded):
itemDateNums.append([])
itemWeights.append([])
itemVolumes.append([])
itemDateNums[1].append("hello world")
But the syntax looks very redundant. Is there an cleaner way of expressing that a copy assign is needed instead of reference assign?