By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

Help with embedding fully qualified script name

P: n/a
I'm trying to call a method in a script file given a fully qualified file
name, e.g. c:\myscript\test.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_GetDict ( pModule );
pFunc = PyDict_GetItemString ( 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_GetDict,
PyDict_GetItemString)
3) Call that function PyObject_CallObject

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

Jim W.

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.