Using Python As an Extensibility Library

kmalloc kmalloc at hotmail.com
Fri Sep 7 06:56:42 EDT 2001


Hi everyone! I have been using Python for some time now and am
impressed by the capabilities stored in this powerful language.

Recently I have been looking a bit into the source code of Python. I
am interested in using Python as an extensibility library for
applications I am writing, much like GNU's Guile is supposed to be.
The goal is to allow applications to run user-written Python code in
contexts they set up for it. Suppose I have an emacs-style text
editor, which will export simple APIs like the following:
OpenDocument will return an instance of a Document class which will
support methods like Save, Close, SaveAs, etc.. I want the client
Python code to be able to call all these APIs, But in order to do so I
have to declare the Document class programatically before running the
client code using the embedding API provided by Python.

I hope the text above is clear so far. Since I am just beginning
programming with the Python/C API, I have several questions:

1) I understand it is possible to run client code using an
already-set-up context containing classes, variables and functions.
How do I exactly do that?
2) I have unsuccessfully tried to programmatically create a Python
class in an existing module dictionary. All I got was an access
violation...
Can anyone explain to me how to do that "the right way"?

I'd really really appreciate any help from you guys...

Thanks in advance...

kmalloc



More information about the Python-list mailing list