New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

usepython

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usepython

A Python scripts runner composable

Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
19
216.67%
Maintainers
1
Weekly downloads
 
Created
Source

Use Python

pub package

A Python scripts runner composable. Run Python scripts in a Pyodide service worker

Install

As a package

npm install usepython
# or
yarn add usepython

Then use it:

import { usePython } from "usepython";

const py = usePython();

As script src

    <script src="https://unpkg.com/usepython@0.0.2/dist/py.min.js"></script>
    <script>
      const py = $py.usePython();
    </script>

As script type module

    <script type="module">
      import { usePython } from "https://unpkg.com/usepython@0.0.2/dist/py.esm.js";
      const py = usePython();
    </script>

Usage

Load the runtime

Load the Python runtime:

await py.load()

Run Python code

Run some Python code:

const script = `a=1
b=2
a+b`
const { result, error } = await py.run("script1", script);

The result is the last line of the script, just like a return value

Listen to stduut

Listen to the Python stdout output:

const script = `print('ok from python')`;
py.log.listen((val) => {
  console.log("LOG", val.stdOut)
});
await py.run("script2", script);

Examples

FAQs

Package last updated on 25 Aug 2022

Did you know?

Socket

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.

Install

Related posts