sbinet / go-python

naive go bindings to the CPython2 C-API
Other
1.53k stars 138 forks source link

Python calls go function #44

Closed zjb0807 closed 8 years ago

zjb0807 commented 8 years ago

In go source: //------------------------------ type mdapi struct { } func (p *mdapi)add(){} //------------------------------ how to call add function in python code ?

sbinet commented 8 years ago

theoretically, you should simply have to follow: https://docs.python.org/2/extending/extending.html#a-simple-example

but that's not easily possible with go-python (especially the PyMethodDef and Py_InitModule parts)

I would recommand github.com/go-python/gopy if you are using go-1.5 (gopy isn't completely compatible with go >= 1.6)