[capi-sig] Constructing variable arg tuples

Todd Lyons tlyons at ivenue.com
Tue May 21 16:27:09 CEST 2013

Hi all, I'm embedding python into a c app (exim, the MTA).  I've
gotten code in to initialize python, read in the embedded script, call
various functions within that script, and appropriately return data
from those functions back to the exim call.

One thing that does not make sense yet though, is how to assemble the
data to be passed to the python functions.  Imagine the following
simple function:

def simple_math(a,b):
     return a+b

In this case, a and b are integers or long integers.  How can I format
that incoming data without knowing in advance that there are two
arguments to this function and that are both are integers?  If the
reason for this question is not clear, imagine that the sysadmin goes
and edits the python script so that it now is:

def simple_math(name,a,b):
     // do something to log "name" to a logfile
     return a+b

Now argument index 0 is a string, and indexes 1 and 2 are the
integers.  How does a calling c application deal with the fact that
the variables to function can be, well, of variable types, and not
known beforehand?  It seems like there should be a python api function
available which says "for $FUNC, are $ARGS valid arguments" or "for
$FUNC, convert $ARGS to what $FUNC expects".

Am I missing something simple here?

The total budget at all receivers for solving senders' problems is $0.
 If you want them to accept your mail and manage it the way you want,
send it the way the spec says to. --John Levine

More information about the capi-sig mailing list