Hi, The String "python myscript.py“ is the command you want to execute with your system’s standard shell. unixCmd is an instance method of the String class, documented here: The method name suggests that it doesn’t work on windows. A simple example might look like this: In SuperCollider write: "python ~/Desktop/hello_sc.py“.unixCmd; The python script is expected to be sitting on the Desktop in this example, with a name of "hello_sc.py" It could contain something simple like this: #!/usr/bin/env python2 print("Hello SuperCollider") print("This is the second Line") If you want to get something back from your script, you can use .unixCmdGetStdOut or .unixCmdGetStdOutLines. With the example script, the later would return an array of two elements (the two lines printed by the python script). a = "python3 ~/Desktop/hello_sc.py".unixCmdGetStdOutLines; a.postln; // -> [ Hello SuperCollider, This is the second Line ] If you want to pass arguments into the script you could use string formating in SuperCollider (see http://doc.sccode.org/Classes/String.html#-format ) ~myFirstArgument = 1234 // Whatever you want to pass in "python3 ~/Desktop/hello_sc.py %".format(~myFirstArgument).unixCmd; and on the python side you would use one of the several options to parse command line arguments. Here’s a quick one: #!/usr/bin/env python2 import sys if len(sys.argv) > 1: print( "Your first argument was {}".format(sys.argv[1]) ) print("Hello SuperCollider“) print("This is the second Line") I think that’s pretty much it. ._. Best, Eric
|
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail