Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:37:42+00:00 2026-06-02T00:37:42+00:00

I am not sure if what I am asking is possible, but it would

  • 0

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]}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:37:44+00:00Added an answer on June 2, 2026 at 12:37 am

    Create a new class that takes H and the paths to the sublists in the initializer, and override __*item__() such that the underlying lists will be affected instead.

    EDIT:

    A partial example:

    class listxer(object):
      def __init__(self, structure, paths):
        self.structure = structure
        self.paths = paths
    
      def _descend(self, path):
        return reduce(lambda x,y: x[y], path, self.structure)
    
      def __len__(self):
        return sum(len(self._descend(path)) for path in self.paths)
    
      def __getitem__(self, item):
        if item < 0:
          raise ValueError('negative indices not supported!')
        for path in self.paths:
          cur = self._descend(path)
          if item > len(cur):
            item -= len(cur)
            continue
          else:
            return cur[item]
        else:
          raise IndexError('list index out of range')
    
    H = [[[1, 2], [3, 4, 5]]]
    
    mystruct = listxer(H, ((0, 0), (0, 1)))
    print len(mystruct)
    print mystruct[3]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if what I'm asking is possible, but I would like to
I'm not sure if what I'm asking is possible at all, but since python
im not sure if what I am asking for is possible... but it probably
I'm sure this is possible but what I am asking for his is not
I'm not sure I'm asking the right question here, but I'm looking to provide
Not very sure if this is the right way of asking, but I was
I may not be asking this in the best way possible but i will
This particular problem is easy to solve, but I'm not so sure that the
Not sure if this is possible with a regular expression replace command, but I
I'm not sure if I'm asking the question the way it should be but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.