[capi-sig] Code for a Python function

Enrico Granata egranata at apple.com
Sat Jul 16 02:44:56 CEST 2011

Dear all,
for my current task I have a Python interpreter embedded in a C++ program.
There are several ways through which the user can interact with this interpreter, typing code into it, and possibly also def-fining functions.
I need to be able to look into all defined functions, find one given its name and (here comes the hard part) read whatever code it currently contains.
I looked into the API and there is a PyCodeObject class, but it is subject to change at any time and I do not want to start using code that might just change the next time the user upgrades Python. Is there any documented and portable-across-versions way to read the code into a Python function just given its name?

Thanks for any help you'll be willing to provide on this

Enrico Granata
✆ 408.974.5572 | ✉ egranata@.com

More information about the capi-sig mailing list