Skip to content
Python to JavaScript compiler
Python
Branch: master
Clone or download
Almar Klein
Latest commit b1e6e8a Dec 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs bump version Mar 29, 2019
examples tweak docs Feb 26, 2018
pscript
tasks
.gitignore More moving code around and renaming Feb 25, 2018
.travis.yml
CONTRIBUTING.md More moving code around and renaming Feb 25, 2018
LICENSE
MANIFEST.in
README.md use markdown for pypi long_description Dec 16, 2019
setup.cfg
setup.py
translate_to_legacy.py bit of cleaning Feb 11, 2016

README.md

PScript

Build Status Documentation Status

PScript is a Python to JavaScript compiler, and is also the name of the subset of Python that this compiler supports. It was developed as a part of Flexx (as flexx.pyscript) and is now represented by its own project. Although it is still an important part of Flexx, it can also be useful by itself.

Installation

PScript is pure Python and requires Python 2.7 or 3.5+ (including Pypy). It has no further dependencies.

  • pip install pscript, or
  • conda install pscript -c conda-forge

Short example

   from pscript import py2js

   def foo(a, b=2):
      print(a - b)

   print(py2js(foo))

Gives:

   var foo;
   foo = function flx_foo (a, b) {
      b = (b === undefined) ? 2: b;
      console.log((a - b));
      return null;
   };

Supported browsers

PScript aims to support all modern browsers, including Firefox, Chrome and Edge. Internet Explorer is in principal supported from version 9, though some constructs (e.g. async and await) do not work in Internet Explorer.

PScript in the wild

To give an idea of what PScript can do, here are some examples in the wild:

  • Obviously, everything built in Flexx uses PScript, see e.g. these examples
  • The front-end of TimeTurtle.app is built in Python using PScript.

Let us know if you know more!

License

PScript makes use of the liberal 2-clause BSD license. See LICENSE for details.

You can’t perform that action at this time.