Question about extending the interperter

Eli elie at flashmail.com
Tue May 10 03:01:54 EDT 2005


Thanks for the answer; I should better explain my problem.

My organization already has a DOS command line tool which I would like
to transffer to Python.
Every function this DOS command line too can execute has a definition
entry in an array:
 {"function name", function address, other info... },
Which means if 'function name' was enetered by the user the command
line tool will call 'function address'. Note that this is a *big*
array.

Now I'm trying to pass the above enteries to Python's interperter
extension:
One way would be going over all of my enteries and add Python calls
like that:

static PyMethodDef pmylib_methods[] = {
{"function name 1", pmylib_1, METH_VARARGS, "..."},
{"function name 2", pmylib_2, METH_VARARGS, "..."},
etc
...
}
The only problem I need to preprocess the input first (initialize
strtok).
So a solution would be creating 'function 1' which preprocess the input
and calls the original function 1, than do so for any other function.
This works, but there are *lots* of such enteries and I'm trying a
general way of doing so.
If I would have the full line the user enetered I could make all of the
extensions to call a general function which will call the original
functions (it can do so because it has the function address as a
parameter).
If I could get the full line the user has entered that would be great,
if that's possible.

Hope I've explained it correctly...
cheers,
Eli




More information about the Python-list mailing list