Skip to content

Instantly share code, notes, and snippets.

@neuro-sys
Created February 24, 2013 22:04
Show Gist options
  • Select an option

  • Save neuro-sys/5025903 to your computer and use it in GitHub Desktop.

Select an option

Save neuro-sys/5025903 to your computer and use it in GitHub Desktop.
pycall
char * py_call_module(char * name, struct irc_t * irc)
{
struct py_module_t * mod = g_hash_table_lookup(mod_hash_map, name);
PyObject * p_args = PyTuple_New(2);
PyObject * p_val;
p_val = PyString_FromString(irc->from);
PyTuple_SetItem(p_args, 0, p_val);
p_val = PyString_FromString(irc->request);
PyTuple_SetItem(p_args, 1, p_val);
p_val = PyObject_CallObject(mod->pFunc, p_args);
return strdup(PyString_AsString(p_val));
}
///////////////////////////////////////////////////////
$ cat modules/mod_test.py
def mod_test(a, b):
return "python test: " % a % " and " % b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment