Python parse embedding in c -


i'm trying embedding 2 python functions in c code. problem can't parse none py object null in c.

i created "check.py" file within it:

def integer(s):     = input(s)     try:         = int(a)         return     except valueerror:         print("invalid input\n")         return #null  def floating(s):     = input(s)     try:         = float(a)         return     except valueerror:         print("invalid input\n")         return #null 

here c code:

#include <python.h>  int inputint() {     pyobject *strret, *mymod, *strfunc, *strargs;     int result;     py_initialize();     pyrun_simplestring("import sys; sys.path.insert(0, '.')");     mymod = pyimport_importmodule("prova");     strfunc = pyobject_getattrstring(mymod, "integer");     strargs = py_buildvalue("(s)", "insert integer value: ");     strret = pyeval_callobject(strfunc, strargs);     //next line problem (can't parse none py object null)     pyarg_parse(strret, "l", &result);     return result; }  double inputdouble() {     pyobject *strret, *mymod, *strfunc, *strargs;     double result;     py_initialize();     pyrun_simplestring("import sys; sys.path.insert(0, '.')");     mymod = pyimport_importmodule("prova");     strfunc = pyobject_getattrstring(mymod, "floating");     strargs = py_buildvalue("(s)", "insert floating point value: ");     strret = pyeval_callobject(strfunc, strargs);     //next line problem (can't parse none py object null)     pyarg_parse(strret, "d", &result);     return result; }  int main(int argc, char** argv) {     long = inputint();     printf("%ld\n", a);     double b = inputdouble();     printf("%.3f\n", b);     return 0; } 

the program compile correctly how can implement none object null in c?


Comments