dictionary questions…

Nov 2, 2011 at 1:31am

dictionary questions…

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!!!

– Pasted Max Patch, click to expand. –
#59738
Nov 2, 2011 at 4:43pm

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.

#215026
Nov 2, 2011 at 6:10pm

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.

#215027
Nov 29, 2011 at 10:32am

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

#215028
Nov 29, 2011 at 11:12am

Found a way of getting dict.pack to act pretty much as dict.group.
Might help you.

– Pasted Max Patch, click to expand. –
#215029
Mar 30, 2013 at 7:11am

Guillaume, thanks for the patch! I had a similar task and that fits the bill nicely.

#215030

You must be logged in to reply to this topic.