I am not sure if what I am asking is possible, but it would be convenient for a particular application if it were. I am building a trial list for an experiment, where a target can either match a prime exactly, or it can be a mismatch in a particular way that maintains a certain relationship to the target. To be even more explicit, all of my stimuli fall into a 3 level taxonomy, of the form:
H = {
'A1':{
'B1':{
'C1':[],'C2':[],'C3':[] },
'B2':{
'C1':[],'C2':[],'C3':[] },
'B3':{
'C1':[],'C2':[],'C3':[] }
},
'A2':{
'B1':{
'C1':[],'C2':[],'C3':[] },
'B2':{
'C1':[],'C2':[],'C3':[] },
'B3':{
'C1':[],'C2':[],'C3':[] }
}
}
Where each list on the bottom the the “tree” is a particular set of stimuli. If the prime and target match, that is simple. If they do not, I want to draw randomly, without replacement, from a different C group under the same B group.
My intended solution was to leverage how (I thought) python handles references and make a temporary list that I could pop() a stimuli from. So, if the trial is incongruent, and the prime is from H[A1][B1][C1], I want to pop() from a list:
tempList = H[A1][B1][C2] + H[A1][B1][C3]
However, presumably because I am appending the two lists, the reference to the lists in the dictionaries is broken, so if I remove an idem from the temp list, it is not reflected in the dictionaries. Is there a way to maintain the reference? Thank you!
EDIT:
This toy example does not work as expected:
>>> d = {'A':[1,2,3],'B':[4,5,6]}
>>> l = d['A'] + d['B']
>>> l
[1, 2, 3, 4, 5, 6]
>>> l.pop(2)
3
>>> l
[1, 2, 4, 5, 6]
>>> d
{'A': [1, 2, 3], 'B': [4, 5, 6]}
Create a new class that takes
Hand the paths to the sublists in the initializer, and override__*item__()such that the underlying lists will be affected instead.EDIT:
A partial example: