PLearn 0.1
|
Include this file when you want to embed the Python interpreter. More...
#include <PythonEmbedder.h>
Public Member Functions | |
PythonEmbedder () | |
~PythonEmbedder () |
Include this file when you want to embed the Python interpreter.
It ensures that Py_Initialize and Py_Finalize are called only once in the entire program. NOTE that it does not include the Python.h header file for you; you must still include those files yourself.
Create one such object that is called early enough in your Python-using code (e.g. a build function before any Python calls are made) ::
static PythonEmbedder python;
Definition at line 63 of file PythonEmbedder.h.
PLearn::PythonEmbedder::PythonEmbedder | ( | ) |
Definition at line 54 of file PythonEmbedder.cc.
References PLearn::endl(), and PLearn::num_python_instances.
{ if (num_python_instances == 0) { MODULE_LOG << "Py_Initialize() called" << endl; Py_Initialize(); } num_python_instances++; }
PLearn::PythonEmbedder::~PythonEmbedder | ( | ) |
Definition at line 64 of file PythonEmbedder.cc.
References PLearn::endl(), and PLearn::num_python_instances.
{ if (num_python_instances > 0) { --num_python_instances; if (num_python_instances == 0) MODULE_LOG << "Py_Finalize() called" << endl; Py_Finalize(); } }