Skip to content

Instantly share code, notes, and snippets.

@lvm
Created January 3, 2018 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvm/c5af0ce6d79725c5d6f18c42ee55096e to your computer and use it in GitHub Desktop.
Save lvm/c5af0ce6d79725c5d6f18c42ee55096e to your computer and use it in GitHub Desktop.
Python {
classvar py;
classvar <py_bin;
var py_pipe;
*initClass{
py_bin = "which python".unixCmdGetStdOut.replace(Char.nl, "").asString;
}
*new {
if(py.isNil){
py = super.new;
py.init();
}
^py;
}
init {
py_pipe = Pipe.new("%".format(py_bin), "w");
"Python is running!".postln;
}
pr_send {
|message|
py_pipe.write("%\n".format(message));
py_pipe.flush;
}
stop {
py_pipe.close;
Python.pr_close;
"Python is stopped!".postln;
}
*pr_close{
py = nil;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment