Skip to content

Repository files navigation

PScript

Build StatusDocumentation Status

PScript is a Python to JavaScript compiler, and is also the name of the subset of Python that this compiler supports. It was originally developed as a part of Flexx and is now a project on its own.

Installation

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

pip install pscript

Short example

frompscriptimportpy2jsdeffoo(a, b=2):
print(a-b)
print(py2js(foo))

Gives:

varfoo;foo=functionflx_foo(a,b){b=(b===undefined) ? 2: b;console.log((a-b));returnnull;};

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:

Let us know if you know more!

License

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

About

Python to JavaScript compiler

Resources

Stars

274 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages