Help with embedding fully qualified script name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Wallace

    #1

    Help with embedding fully qualified script name

    I'm trying to call a method in a script file given a fully qualified file
    name, e.g. c:\myscript\tes t.py. I find that PyImport_Import ("test") works
    fine, with c:\myscript is set as the first item in the PYTHONPATH.

    I tried PyRun_Simple and that does run my specific file, but then when I try
    to use the calls below that I used on PyImport_Import , I get a null function
    returned. I've tried the other methods that use a FILE and they do the same
    thing.

    pDict = PyModule_GetDic t ( pModule );
    pFunc = PyDict_GetItemS tring ( pDict, "MyFunction " );

    I also tried doing things like creating a new module, etc. since I thought
    that may work, but suspect that I was missing some steps.

    The basic flow I want to do is this, with only the first step being my
    problem.

    1) Load the script file ??
    2) Get the function "MyFunction " from the script (PyModule_GetDi ct,
    PyDict_GetItemS tring)
    3) Call that function PyObject_CallOb ject

    I appreciate any help since I've spent quite a bit of time searching and
    trying things.

    Jim W.



Working...