
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
jspython-interpreter
Advanced tools
JSPython is a javascript implementation of Python language that runs within web browser or NodeJS environment
JSPython is a python-like syntax interpreter implemented with javascript that runs entirely in the web browser and/or in the NodeJS environment.
It does not transpile/compile your code into JavaScript, instead, it provides an interactive interpreter that reads Python code and carries out their instructions. With JSPython you should be able to safely use or interact any JavaScript libraries or API with a nice Python language.
arr = [4, 9, 16]
def sqrt(a):
return Math.sqrt(a)
# use Array.map() with Python function
roots = arr.map(sqrt).join(",")
# use Array.map() or use arrow function
roots = arr.map(i => Math.sqrt(i)).join(",")
Interactive Worksheet Systems JSPython editor with an ability to query REST APIs and display results in Object Explorer, a configurable Excel-like data grid or just as a JSON or text.
You can easily embed JSPython into your web app and your end users will benefit from a Python like scripting facility to:
Our aim here is to provide a SAFE Python experience to Javascript or NodeJS users at run-time. So far, we implement a core set of Python feature which should be OK to start coding.
Syntax and code flow Same as Python, In JSPython we use indentation to indicate a block of code. All flow features like if - else, for, while loops - along with break and continue
Objects, Arrays JSPython allows you to work with JavaScript objects and arrays and you should be able to invoke their methods and properties as normal. So, all methods including prototype functions push(), pop(), splice() and any more will work out of box.
JSON JSPython allows you to work with JSON same way as you would in JavaScript or Python dictionaries
Functions Functions def def async def, arrow functions => - (including multiline arrow functions)
Strings Syntax and code flow s = "Strings are double quoated only! For now." represent a multiline string. A single or triple quotes are not supported yet.
Date and Time We have dateTime() function what returns JavaScript's Date object. So, you can use all Date get and set methods
None, null null and None are synonyms and can be used interchangeably
Although we haven't implemented all the features available in Python yet. But, we already have a several usefull and distinctive features that are popular in other morden languages, but not in Python:
=> (no lambda keyword required)=>. Particularly usefull when building data transformation pipelinesmyObj?.property?.subProperty or "N/A".Zero install ! The most simple way to get started, without anything to install, is to use the distribution available online through jsDelivr. You can choose the latest stable release :
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jspython-interpreter/dist/jspython-interpreter.min.js">
</script>
Or local install
npm install jspython-interpreter
Run JS Python from your Javascript App or web page.
jsPython()
.evaluate('print("Hello Worls!")')
.then(
r => console.log("Result => ", r),
e => console.log("Error => ", error)
)
const script = `
x = [1, 2, 3]
x.map(r => add(r, y)).join(",")
`;
const context = {y: 10}
const result = await jsPython()
.addFunction("add", (a, b) => a + b)
.evaluate(script, context);
// result will be a string "11,12,13"
Also, you can provide entire JS Object or even a library.
JSPython-cli is a command line tool what allows you to run JSPython in NodeJS environment
A permissive BSD 3-Clause License (c) FalconSoft Ltd.
FAQs
JSPython is a javascript implementation of Python language that runs within web browser or NodeJS environment
We found that jspython-interpreter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.