You are here

Passing a dictionary from pyrosetta to rosetta

2 posts / 0 new
Last post
Passing a dictionary from pyrosetta to rosetta
#1

Hi,

I'd like to create a function in rosetta (in C++) that ultimately will accept a python dictionary when called from pyrosetta.  What's the best C++ class to use that will be the easiest for me to do the conversion from python dict?  (i.e. is there any existing pyrosetta code that will convert a python dictionary to, say, a C++ map).

Thanks in advance.

Category: 
Post Situation: 
Mon, 2017-11-13 11:33
SenyorDrew

I'd probably recommend a two-function approach: Create the C++ function how you would, using the special wrapped-map object. Then on the Python/PyRosetta side make a simple wrapper function which takes a standard Python dict and converts it to the needed C++ version.

There's a bunch of issues working with Python objects on the C++ side, not the least of which is that Python dicts can contain arbitrary objects in a mixed fashion. Having a wrapper on the Python side allows you to easily clean up/check the contents of the dict before passing it to the C++ interface.

Fri, 2017-12-01 10:10
rmoretti