Created
January 3, 2018 23:05
-
-
Save lvm/c5af0ce6d79725c5d6f18c42ee55096e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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