I'm embedding Python into a C++ application. I plan to use PyEval_EvalCode
to execute Python code, but instead of providing the locals and globals as dictionaries, I'm looking for a way to have my program resolve symbol references dynamically.
For example, let's say my Python code consists of the following expression:
bear + lion * bunny
Instead of placing bear
, lion
and bunny
and their associated objects into the dictionaries that I'm passing to PyEval_EvalCode
, I'd like the Python interpreter to call back my program and request these named objects.
Is there a way to accomplish this?