On Wed, Oct 15, 2014 at 3:16 PM, flaye <[email protected]> wrote:
>
>
> Solved it:
>
> Tried initially
> self.dHandles[limbName]=allHandles
>
> but the dictionary kept returning only one value list.
>
> Tried also
> self.dHandles[limbName].append(allHandles)
>
> with the same result.
>
> Finally, got this to work like a charm:
>
>
> self.dHandles.setdefault(limbName,[]).append(allHandles)
>
>
> Cool. Glad you figured that out. I had thought I clarified that bit
already when I was saying to first check if the key exists, and if not, set
it to an empty list. But you discovered the setdefault bit anyways. Also
this has been abstracted into something called "defaultdict" in the
standard lib
from collections import defaultdict
d = defaultdict(list)
d['foo"].append("bar")
>
> Had to do some digging, but happy with the result, and a lot cleaner than
> my original code. Justin, thanks again for pointing out the redundancy.
>
> @Eduardo: Thanks for the red9 links. Great stuff indeed. I'm on purpose
> trying to get my own code in place. I'm writing an introductory primer on
> rigging for those who want to learn how to be a TD. Part of the trial and
> error process.
> As for the message nodes, definitely something to explore, but that's a
> more advanced stage.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/810e971a-2385-4a31-b32d-801cdee83d35%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/810e971a-2385-4a31-b32d-801cdee83d35%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0k28sjrNuCQ5D0kXw%3DLX4igKRdXdnNkMjaqxMPcSEk9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.