module is in the folder - what am i doing wrong??

Trung Hoang thoa0025 at mail.usyd.edu.au
Sun Mar 24 07:06:04 EST 2002


Also forgot to mention,

in the python interpreter i performed the following commands

Python 2.1.2 (#2, Jan 18 2002, 11:23:35)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> modname = "xml"
>>> mod = __import__(modname)
>>> mod
<module 'xml' from 'xml.py'>
>>>

which shows, the module does exist and accessible from the interpreter.. but
why when i run my code, it doesnt work??

hope someone knows :( im getting sad..

cheers
trungie

"Trung Hoang" <thoa0025 at mail.usyd.edu.au> wrote in message
news:bajn8.5630$EE4.21273 at news-server.bigpond.net.au...
> Thanks for your reply Jim,
>
> i have a file "xml.py" and it has a function named "getProjects()" and i
> simply wish to access it from c. i have the source....
>
> #include <Py/Python.h>
>
> int main (int argc, char *argv[]) {
>         // declare variables
>         PyObject *modname = NULL;
>         PyObject *mod = NULL;
>
>         // init
>         Py_Initialize();
>
>         modname = PyString_FromString("xml");
>         mod = PyImport_Import(modname);
>         if (mod == NULL) printf("mod is null\n");
>
>         Py_XDECREF(mod);
>         Py_XDECREF(modname);
>         Py_Exit(0);
> }
>
> but when i try to run it, it prints "mod is null", meaning it cant find
the
> module. but the module is named "xml.py" and is in the current folder!!
what
> am i doing wrong???
>
> i dont see why it is so hard. it's just that ive fallen in a small hole
> (idom).. just one of those things when you learn a new language... i just
> need a little help. im sure someone knows :(
>
> ive thought of using exec, but this way is far more elegant.. so i've
read.
> but not proven.
>
> Please HELP!
> Cheers
> Trung Hoang
> Final year Undergraduate of Computer Science and Technology
> University of Sydney, Australia.
>
>





More information about the Python-list mailing list