Skip to content
This repository has been archived by the owner. It is now read-only.

kovidgoyal/dukpy

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

dukpy

Build status of the master branch on Unix Build status of the master branch on Windows Code coverage

dukpy is a JavaScript runtime environment for Python (tested with python 2.7 and >= 3.4) using the duktape embeddable JavaScript engine. With dukpy, you can run JavaScript in Python.

Example:

import dukpy

ctx = dukpy.Context()
ctx.eval('str = "Hello, World!";');

# ctx.g to refers to the global object
print(ctx.g.str)
# ==> Hello, World!

# Python functions can be called from JavaScript
def add(x, y):
    return x + y

ctx.g.add = add
ctx.eval('result = add(10, 32);')
print(ctx.g.result)
# ==> 42

# JavaScript functions can be called from Python
ctx.eval('var sub = function (x, y) { return x - y; };')
print(ctx.g.sub(52, 10))
# ==> 42

About

JavaScript in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •