DICTIONARIES ... again

Hello -

I’m still struggling again with Dictionaries inside the PyNodes.

I try to create a Dictionary from a flattened list, but is giving me this error:

"
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
‘int’ does not contain a definition for ‘Key’

"

In IronPython ( and of course Python) works well.

@ the creators of Dynamo: why this issue? In theory what works in IronPython should work the same inside PyNodes, or it is not? Please can you point out where we can find documentation for these issues?

Thanks for your help!

You cant output dictionaries from Python nodes. Its not supported and a known issue. You could simply return the values and the keys as sublists

1 Like

@Thomas_Mahon - thanks. I knew about that issue, but I was hoping somebody had fixed it (or explain clearly why it’s not working)
Too bad that I cannot use dictionaries, as performing fast lookups for large datasets was something very good to have inside pynodes.
Yes, I can pull the values and indexes in separate lists in this case and select via a lambda, though in other projects I have to export via .csv and use Pandas/NumPy.
Thanks for your help!

You cannot OUTPUT dictionaries. That doesn’t mean you cannot use them in Python nodes. It’s fine to use them, it will just fail when you pass it a dictionary to the OUT variable. That makes debugging a little weird, but it’s very possible.

1 Like

@Adrian_Crisan
As a workaround you can create a class that behaves likes a dictionary. This will allow you to output it and exploit it in another python node :

4 Likes