Skip to content

Instantly share code, notes, and snippets.

@anthonymorast
Created November 28, 2021 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonymorast/c910125468ea362824da458aca2818bf to your computer and use it in GitHub Desktop.
Save anthonymorast/c910125468ea362824da458aca2818bf to your computer and use it in GitHub Desktop.
// construct keyword args
PyObject* kwargs = PyDict_New();
for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it) {
// recommendation from: https://github.com/lava/matplotlib-cpp/issues/75
if (it->first == "alpha")
PyDict_SetItemString(kwargs, it->first.c_str(), PyFloat_FromDouble(std::stod(it->second)));
else
PyDict_SetItemString(kwargs, it->first.c_str(), PyUnicode_FromString(it->second.c_str()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment