Skip to main content

Run JavaScript code from Python

Project description

Run JavaScript code from Python.

PyExecJS is a porting of ExecJS from Ruby. PyExecJS automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Python object.

A short example:

>>> import execjs
>>> execjs.eval("'red yellow blue'.split(' ')")
['red', 'yellow', 'blue']
>>> ctx = execjs.compile("""
...     function add(x, y) {
...         return x + y;
...     }
... """)
>>> ctx.call("add", 1, 2)
3

Of course, you can pick particular JavaScript runtime by get() function:

>>> default = execjs.get() # the automatically picked runtime
>>> default.eval("1 + 2")
3
>>> jscript = execjs.get("JScript")
>>> jscript.eval("1 + 2")
3
>>> node = execjs.get("Node")
>>> node.eval("1 + 2")
3

If EXECJS_RUNTIME environment variable is specified, PyExecJS pick the JavaScript runtime as a default:

>>> #execjs.get().name # this value is depends on your environment.
>>> os.environ["EXECJS_RUNTIME"] = "Node"
>>> execjs.get().name
'Node.js (V8)'

PyExecJS supports these runtimes:

# Installation

$ pip install PyExecJS

or

$ easy_install PyExecJS

# License

Copyright (c) 2012 Omoto Kenji. Copyright (c) 2011 Sam Stephenson and Josh Peek.

Released under the MIT license. See LICENSE for details.

#Changes 1.0.4 : Removed “import execjs” (it prevent execution of setup.py by Python 2.6) 1.0.3 : Javascript sources were embeded in __init__.py. ‘which’ command were reimplemented by pure python. 1.0.2 : Python 2.6.x was supported. 1.0.1 : Forgotten shell=True was added to Popen. 1.0.0 : First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

PyExecJS-1.0.4.zip (14.2 kB view details)

Uploaded Source

PyExecJS-1.0.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

PyExecJS-1.0.4-py3.2.egg (17.0 kB view details)

Uploaded Egg

PyExecJS-1.0.4-py2.7.egg (16.9 kB view details)

Uploaded Egg

PyExecJS-1.0.4-py2.6.egg (17.2 kB view details)

Uploaded Egg

File details

Details for the file PyExecJS-1.0.4.zip.

File metadata

  • Download URL: PyExecJS-1.0.4.zip
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyExecJS-1.0.4.zip
Algorithm Hash digest
SHA256 f111c1de6e639df8d0e2f2c740afe40673d95a6172277cc563426d0b9e09d255
MD5 84be9467a02e4208fede7e231ee3b8ca
BLAKE2b-256 6b29b04a8f6505036c00d7663e4471463cf84eaf05e118de50c58578d87e4267

See more details on using hashes here.

File details

Details for the file PyExecJS-1.0.4.tar.gz.

File metadata

  • Download URL: PyExecJS-1.0.4.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyExecJS-1.0.4.tar.gz
Algorithm Hash digest
SHA256 c8d7bb471a53c84b078aeae2843eae67fb22635b82c25d6eef70c08b36f83791
MD5 63452004bca6ab6acdaa26a3bf09cc7c
BLAKE2b-256 ef14cf5da7242fcc87439317b6acf801f97a1e4f6a5a0ae737644be0c9837cb0

See more details on using hashes here.

File details

Details for the file PyExecJS-1.0.4-py3.2.egg.

File metadata

  • Download URL: PyExecJS-1.0.4-py3.2.egg
  • Upload date:
  • Size: 17.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyExecJS-1.0.4-py3.2.egg
Algorithm Hash digest
SHA256 42b1b8631bc2628eb4e2d9cc117a7b01783b7fe7d22a7ac717f4a8c02df0f509
MD5 cc988d0cfcae3ab508aa8c89022512a1
BLAKE2b-256 09fecec59038a55e04fccf85ebbbb42826692ace033d715c7a2f0703eb2f1599

See more details on using hashes here.

File details

Details for the file PyExecJS-1.0.4-py2.7.egg.

File metadata

  • Download URL: PyExecJS-1.0.4-py2.7.egg
  • Upload date:
  • Size: 16.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyExecJS-1.0.4-py2.7.egg
Algorithm Hash digest
SHA256 c6ff769ca00efc1dac15cbbe46f5fcbc562133c2fb97e28ce26b5257bfd83a1a
MD5 ac84938f5faa68a1e1a626a66c28ea7b
BLAKE2b-256 bd303d029b809fc6f940e58990a545e27dd49339ce7a3be7d6c3aa480c95b996

See more details on using hashes here.

File details

Details for the file PyExecJS-1.0.4-py2.6.egg.

File metadata

  • Download URL: PyExecJS-1.0.4-py2.6.egg
  • Upload date:
  • Size: 17.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyExecJS-1.0.4-py2.6.egg
Algorithm Hash digest
SHA256 23996de7eeb0cb3026a0580c010a1280c08769196d33c372c4c3cd19543a1edd
MD5 307e42dd572fe7b9dc7cfa4c3bffff14
BLAKE2b-256 66a2c8fcbec7bfa28a75d509244c902621e2140d67fa3c056db559db8d074ce0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page