Skip to main content

Python to JavaScript compiler.

Project description

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.

Project details


Download files

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

Source Distribution

pscript-0.7.2.tar.gz (120.8 kB view details)

Uploaded Source

File details

Details for the file pscript-0.7.2.tar.gz.

File metadata

  • Download URL: pscript-0.7.2.tar.gz
  • Upload date:
  • Size: 120.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

File hashes

Hashes for pscript-0.7.2.tar.gz
Algorithm Hash digest
SHA256 7cd6da5e1ba69b6f1058bae903841343adec06e64585de01b64739c9a64983c0
MD5 abde26ef88f5b0a2b9064dec4d97a4a8
BLAKE2b-256 08734ed19251ab2c12603d7b2697fb29415635b2ebbbd456db5e678c791ccd6e

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