I'm trying to extend Python interpreter by a few C functions I wrote. From reading docs, to expose those function the user has to import the module encompassing the functions.
Is it possible to load pre-load or pre-import via C API the module so that the user doesn't have to type import <mymodule>
? Or even better, from <mymodule> import <function>
?
Edit: I can do PyRun_SimpleString("from mymodule import myfunction") just after Py_Initialize(); - I was just wondering if there is another way of doing this..?
Edit 2: In other words, I have an application written in C which embeds a Python interpreter. That application provides some functionality which I want to expose to the users so they can write simple Python scripts for the app. All I want is to remove the need of writing from mymodule import myfunction1, myfunction2
because, since it is very specialized app and the script wont work without the app anyway, it doesn't make sense to require to import ...
all the time.