msqrd at lanl.gov
Fri Aug 2 00:16:53 EDT 2002
Andrew - sure - thanks!
void get_value(char *Block, char *VarName, int *Value, int *counter)
/*retrieve function - tmode is python module that has been loaded*/
get_method = PyObject_GetAttrString(tmod, "get_value");
if (get_method == NULL)
error("Can't get python_input.get_value()");
method_args = Py_BuildValue("(ssi)", Block, VarName, counter);
if (method_args == NULL)
error("Can't build arguments lists");
py_object = PyObject_CallObject(get_method,method_args);
if (py_object == NULL)
error("Error calling python_input.get_value()");
/*convert to C*/
/* things work here great if I am returning a string! but not anything
PyArg_Parse(py_object, "s", &ccstr);
printf ("here it is %s\n", ccstr);
from UISF import *
# This function's purpose is to look up a variable in a
# python dictionary associated with the blocktype in question
def get_value(blocktype, var, count):
for block in NameListList.TheNameList.ListofNameLists:
if block.BlockType == blocktype:
if block.ID == count:
val = block.__dict__[var]
"Andrew Wilkinson" <ajw126NO at SPAMyork.ac.uk> wrote in message
news:s4U19.2559$sH3.82946 at newsfep1-win.server.ntli.net...
> Can you post some code? That'd make it a lot easier to spot any mistakes.
> Andrew Wilkinson
> "Michelle L. Murillo" <msqrd at lanl.gov> wrote in message
> news:215127f6.0207301417.65343257 at posting.google.com...
> > Hi - I have successfully used PyArg_Parse and
> > PyInt_AsLong to parse data from python into C. The
> > data are being returned to C from a python script
> > that does a look up into a dictionary. I can
> > successfully return and print out an integer and
> > a string. But what I can't figure out is how to
> > get PyArg_Parse (or which ever API works) to
> > correctly parse a python tuple - that is we
> > have a value in the dictionary that is in the
> > form of (8,8,8). If I make this a string all
> > works fine - but with out the quotes all that
> > is returned and printed out is garbage.
> > Any ideas?
> > TIA
> > Michelle
More information about the Python-list