Executing javascript from python using Naked.toolshed.shell: How can I execute JavaScript code from Python? Answered my question fine, But is there any way to do this AND pass an argument through to be executed? like
from Naked.toolshed.shell import execute_js
response = execute_js('file.js', arg1) # arguments to pass
if response.exitcode == 0:
print(response.stdout)
else:
sys.stderr.write(response.stderr)
while file.js may look something like
var x = 10;
x = 10 - arg1; // to pass argument here
console.log(x);
function greet() {
console.log("Hello World!");
}
greet()
Is there a way to accomplish this?
subprocessmaybe? related: stackoverflow.com/questions/31464354/…