0

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
2
  • 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. Commented 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. Commented Dec 9, 2014 at 9:26

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.