{"library":"pscript","title":"pscript Python to JavaScript Compiler","description":"pscript is a Python-to-JavaScript compiler that allows developers to write Python code that runs directly in a JavaScript environment, such as a web browser or Node.js. It supports converting Python functions and basic data structures into their JavaScript equivalents, enabling seamless integration of Python logic into web applications. The current version is 0.8.1, with releases occurring periodically, often tied to Python version support updates.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pscript"],"cli":{"name":"pscript","version":"sh: 1: pscript: not found"}},"imports":["from pscript import pyscript","from pscript import Script"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from pscript import pyscript\n\n@pyscript\ndef hello_js(name):\n    # This Python code will be transpiled to JavaScript\n    print(f'Hello, {name} from JavaScript!')\n    return f'Greetings, {name}'\n\n# The generated JavaScript source code\njs_code = hello_js.source\nprint(js_code)\n\n# Example of using the generated function in a browser context (conceptual)\n# You would typically inject js_code into an HTML <script> tag\n# For example, in browser console:\n# hello_js('World'); // Should print 'Hello, World from JavaScript!' to console\n","lang":"python","description":"This quickstart demonstrates how to define a Python function decorated with `@pyscript` to automatically generate its JavaScript equivalent. The generated JavaScript source code can then be embedded and executed in a JavaScript runtime environment.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}