Solution: test_dict = copy.deepcopy(DICT)
Thank you, my fellow gamers. May ease of debugging grace you in the future.
I create a copy of a dictionary, I append change to new variable. Change appears in old variable instead.
CHARACTERS = ['A', 'G', 'T', 'C', 'C', 'A', 'G', 'T', 'G', 'T', 'A', 'A']
DICT = {'key1': "foo", 'key2': "bar", 'key3': CHARACTERS}
def test(self):
test_dict = DICT.copy() # first reference of 'test_dict'
print("DICT before", DICT)
test_dict['sequence'] += ['G']
print("DICT after ", DICT)
Output:
DICT before {'key1': "foo", 'key2': "bar", 'key3': ['A', 'G', 'T', 'C', 'C', 'A', 'G', 'T', 'G', 'T', 'A', 'A']}
DICT after {'key1': "foo", 'key2': "bar", 'key3': ['A', 'G', 'T', 'C', 'C', 'A', 'G', 'T', 'G', 'T', 'A', 'A', 'G']}
The letter 'G' is appended to both DICT and test_dict.
Totally spoopy, if you ask me.
Update: I've tried the suggested: test_dict = DICT.copy()
but with no luck. What am I doing wrong in the above updated code that includes this?