A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/086909.html below:

python embedded in C program, how to import?

python embedded in C program, how to import?Harald Kirsch kirschh at lionbioscience.com
Tue Apr 17 05:48:09 EDT 2001
I tried this (PYCHECK does some error checking):

    PyObject *pymodMain;
    PyObject *pymodRe;
    Py_Initialize();
    pymodMain = PyImport_ImportModule("__main__");
    globals = PyModule_GetDict(pymodMain);
    locals = PyDict_New();
    PyRun_String("import re", Py_file_input, globals, locals);
    PYCHECK;

Then I run:
    PyRun_String("print globals()", Py_file_input, globals, locals);

and get:

{'__doc__': None, '__name__': '__main__', '__builtins__': <module '__builtin__' (built-in)>}

You see that 're' is not in globals. Why? How do I have to import re
such that it is available for example to string I run with
PyRun_String?

  Harald Kirsch

-- 
----------------+------------------------------------------------------
Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
LION bioscience | +49 6221 4038 172          |        -- Paul Erdös

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4