Alan Baljeu wrote:
I was reading some legacy code we have here, and discovered an unexpected 
idiom.  Starting from C++, we create a dictionary, store a few named constants 
in there, and then call PyEval_EvalCode passing in the dictionary.  The code it 
calls is a bunch of python files generated from a CAD model, with no function 
definitions.  It works of course.  Question is, what do you think of this 
approach?  What is a more typical idiom?

I don't quite understand the question. What I think of this approach depends a lot on what you use it for. Typical for what ?

Having a C++ application run some python script that has access to some of the application state (i.e., whatever you expose through the dictionary) is certainly a fine way to make your application scriptable.
(FWIW, boost.python offers 'exec()' and 'eval()' for this.)

Regards,
      Stefan

--

     ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to