dictionary questions...

    Nov 02 2011 | 1:31 am
    I am trying to get my head around the new dict data structure. I think I am understanding how to use it in a "regular" setting. Here is what I wanted to try but couldn't make work:
    I have a data structure that stores several values like pitch, velocity, channel, etc. putting that together with dict.pack is very easy. Now I would like to store each changed structure in a master dict:
    { "note1": ["dataStructureDICT"] "note2": ["dataStructureDICT"]
    "noteX": [....] }
    I assumed that I could use dict.group and append each new dict into my master dict. Problem seems to be that dict.pack doesn't output a new reference for a changed dict but the same one, which means I get the same copy of dict for all my keys...
    Is dict supposed to be able to do what I want here? Am I missing something fundamental about this data type?
    Thanks for any clues!!!

    • Nov 02 2011 | 4:43 pm
      It seems to me that you could do this with a dict of lists, unless you for some reason really want them to be dicts. If there's a way to manipulate these in JS, then you could probably easily make different instances. I haven't had much experience with dicts yet. As I mess with them more, maybe I can get you a better answer.
    • Nov 02 2011 | 6:10 pm
      true, but I was hoping to be able to do dict of dicts... maybe this isn't the best example. I am just trying to get to know the new data type. I'll keep hunting as well and report back if I find anything else.
    • Nov 29 2011 | 10:32 am
      I'm also interested in a making dicts containing a dynamic amount of dicts. That's why dict.pcak is not what I'm looking for, since the number of dict is static.
      Dict.group sounds right but can't figure out how. I keep getting the "dict.group: could not create dictionary from args" error.
      Have you found a solution to do so? Or maybe another way (using js for instance)? Thanks
    • Nov 29 2011 | 11:12 am
      Found a way of getting dict.pack to act pretty much as dict.group. Might help you.
    • Mar 30 2013 | 7:11 am
      Guillaume, thanks for the patch! I had a similar task and that fits the bill nicely.