I need to execute a Javascript function from Python 3 (pass a few variables into it's environment and collect the result). I found pyv8 and python-spidermonkey, but neither supports Python 3.
Is there a library for that job?
asked Sep 26, 2014 at 12:39
Bartosz Marcinkowski
6,9014 gold badges41 silver badges72 bronze badges
-
Are you sure you don't want to expose the JS function as a "web service method"? Probably a lot cleaner than "embedding a JS exe env" => expose your functions as NodeJS HTTP endpoints.smassey– smassey2014年09月26日 12:59:38 +00:00Commented Sep 26, 2014 at 12:59
-
ok, this is a total hack, but you could use mongodb to do that. it supports native js evaluation and its bindings are up to date.Dima Tisnek– Dima Tisnek2014年12月09日 09:26:00 +00:00Commented Dec 9, 2014 at 9:26
1 Answer 1
What you can always do:
Install Node.Js binaries on the server-side
Write a script as standalone .js file
Pass input as command-line arguments, pipes (stdin) or files
Execute the script using subprocess
Collect the result from a named pipe or file output
.js scripts can be executed in similar fashion as .sh and .py scripts.
answered Sep 26, 2014 at 12:43
Mikko Ohtamaa
85.1k63 gold badges297 silver badges482 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default