Get dictionary from python #2735
-
Hey how do you actually get a dictionary from a python file I'm using from_code to run a py file but when I call the file I haven't figured out how to get the dictionary from python to rust |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I have the following code: `
my file py_app returns a dictionary like
on the print result? i get: my question is how can i extract that result to something that i can use in rust |
Beta Was this translation helpful? Give feedback.
-
It depends. If you want to keep working with it as a Python object, you can already use its methods from PyAny, and you can get to PyDict using If you want to convert everything to Rust, i.e. a HashMap, use extract (). |
Beta Was this translation helpful? Give feedback.
-
@birkenfeld got it thanks |
Beta Was this translation helpful? Give feedback.
It depends. If you want to keep working with it as a Python object, you can already use its methods from PyAny, and you can get to PyDict using
result?.downcast::<PyDict>()?
.If you want to convert everything to Rust, i.e. a HashMap, use extract ().