sbinet / go-python

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

Module and high-level interface to executing a python script #16

Closed tfogal closed 9 years ago

tfogal commented 9 years ago

My project creates a "python" module, auto-imports it into the current python context/interpreter, and then runs a script (which presumably accesses the module I created). This implements the machinery that was missing for me to do this via go-python.

One thing of potential note/issue is that I have slightly changed the syntax of PyRun_SimpleFile. The original API takes an already-opened FILE*. However, since this is a huge pain in Go, I stepped around the issue by having it take only a file name. While one can, in C, re-execute the same python script simply by fopen(3)ing the .py file once and rewind(3)ing it for every execution, my approach here means this is not possible in Go: the file must be opened anew for each execution.

This is fine for my uses; is it correct for go-python, though?

sbinet commented 9 years ago

apart from the small inline comments, looks fine to me.

tfogal commented 9 years ago

Ping?

sbinet commented 9 years ago

Sorry. I didn't notice you had update the code.

tfogal commented 9 years ago

No worries! + thanks.