Boost::Python: Dictionary

From Sidvind
Jump to: navigation, search

Boost::Python series

Site: boost.org (Documentation)

[edit]

Importing[edit]

Code: Import a dictionary into C++

  1. object main_module = import("__main__");
  2. object main_namespace = main_module.attr("__dict__");

Exporting[edit]

Code: Export a dictionary from C++

  1. boost::python::dict createDict(){
  2.         boost::python::dict d;
  3.         d["foo"] = 3.5f;
  4.         d["bar"] = 2.7f;
  5.         return d;
  6. }