Calling Python functions from C from strings

Makhno mak at imakhno.freeserve.co.uk
Sat Mar 11 13:00:47 EST 2000


I can easily call a Python function when I am handed a reference to the
function as a PyObject*, but how do I call a Python function (from C) when
all I have is its name? eg:

def mysub:
    print 'hello world'
    ...

And all I have is the string "mysub", how do I call this function? In Perl I
would use perl_call_argv().

I need to use a string, rather than a PyObject* because portability to other
languages is an issue, and a storing a string reference to a function seems
like the best way.








More information about the Python-list mailing list