Extending/Embedding python

"Martin v. Löwis" martin at v.loewis.de
Thu Sep 2 02:27:04 EDT 2004


Alicia Haumann wrote:
> 1.  (Not extending/embedding related at all)  How can I pass in a load/bunch
> of defines so I can use them over and over again, instead of having to copy
> them in every *.py script.

You should use PyModule_Add<Foo>Constant.

> 2.  A couple simple examples I've seen for initModule() are written
> differently.  One only calls Py_InitModule("module", module_methods), but
> the other also calls PyImport_AddModule("module").  What is the difference?
> What does PyImport_AddModule() accomplish?

See

http://docs.python.org/api/importing.html

> 3.  When embedding Python into my simple application, why can't I pass
> application parameters?  PyRun_SimpleString seems to only take hard-coded
> values.  Can/How can I get around this? 

Don't use PyRun_SimpleString; use PyObject_CallFunction/Method instead.

HTH,
Martin



More information about the Python-list mailing list