1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import sys sys.path.insert(0,'..') import inline_tools support_code = """ PyObject* length(std::string a) { int l = a.length(); return PyInt_FromLong(l); } """ a='some string' val = inline_tools.inline("return_val = length(a);",['a'], support_code=support_code) print val