Extend/Embed Python Method table Dispatcher
heath7952 at my-deja.com
heath7952 at my-deja.com
Thu Jul 20 20:27:57 EDT 2000
Dear All,
I am extending Python with my own C functions. I would like be able to
share one C function amongst different extended commands. Here's a
little pseudo example.
// standard method table with two commands specified "do_stuff" and
"do_stuff2" both of which call the same C function.
static PyMethodDef my_methods[] = {
{"do_stuff", (PyCFunction)Python_Embed::fnDoStuff, METH_VARARGS,
dostuff__doc__ },
{"do_stuff2", (PyCFunction)Python_Embed::fnDoStuff, METH_VARARGS,
dostuff2__doc__ },
{NULL, NULL}
};
PyObject* Python_Embed::fnDoStuff(PyObject* self, PyObject* args)
{
switch(who called me)
case do_stuff:
do something
break;
case do_stuff2
do something different.
break;
}
I looked at args, but I was unable to find anything in the PyObject
worth extracting for this purpose.
Any help would be greatly appreciated.
Heath.
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list