Converting _node* to a Code object?

Brendon Costa brendon at
Sun Apr 1 06:35:59 CEST 2007

Hi All,

I have an application with an embedded python interpreter and i need to
get the embedded interpreter to "import" strangely named files as python

Anyhow the simple part of the question is:

How do i convert a _node* object returned from:

into a code object i can use as a module to import with:

I cant seem to find any documentation about this. If you are wondering
why i want to do this, then you can read on and maybe there is a much
better way to achieve what i am after.


----- What i am trying to achieve -----

Basically i want to "import" using the python C API a module from
various files which may have names that do not make valid python module

In particular i have an embedded python interpreter that is used to
apply a number of operations on some data based on a user supplied
"suppressions file" (*.eds). This .eds file is just a python source file
designed only to be used from within this application.

Now the names of these suppression files usually matche that of a
library or application to which they will apply to. For example: : has eds file:

Now i want to have my code import this eds file as a python module so
that i can then use it as any other standard python module. So i need to
separate the name of the module from the name of the file. I was
thinking for example for the above filename i would give it a module
name like:


(The name is not important just that the above one is a valid module
name from what i understand and it is based on the original name)

So i have some random file:

and i want to be able to import that as a module using the Python C API
so native python code can access the module like:


If you have any better method of doing this, i would love to know what
it is.

Thanks in advance for any help,

More information about the Python-list mailing list