npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pyscript-lang

v3.0.0

Published

🐍 Python-like syntax that transpiles to JavaScript and runs on Node.js | Sintaxe estilo Python que transpila para JavaScript e roda no Node.js

Readme

🐍 PyScript

English | Português

npm version License: MIT Node.js

Write Python, Execute JavaScript


English

🐍 Python-like syntax that runs on Node.js. No Python installation required!

PyScript is a transpiler that converts Python-like syntax into JavaScript, allowing you to write code with Python's elegant syntax while leveraging the entire Node.js ecosystem.

✨ Features

  • 🎯 Python-like syntax - Write code that looks and feels like Python
  • Runs on Node.js - No Python installation required
  • 🔄 Real-time transpilation - Converts your code on the fly
  • 📦 Easy to use - Simple CLI interface
  • 🎨 Beautiful error messages - Clear and helpful error reporting

🚀 Installation

npm install -g pyscript-lang

Or use it locally:

npm install pyscript-lang

📖 Quick Start

Command Line:

# Run a PyScript file
pyscript myfile.pys

# Or use the short alias
pys myfile.pys

Programmatic:

const PyScript = require('pyscript-lang');
const code = 'log("Hello from PyScript!")';
PyScript.run(code);

🎓 Syntax Guide

Print/Log:

log("Hello, World!")
log("Value:", 42, "Multiple", "arguments")

Variables:

name = "PyScript"
age = 2
active = True
nothing = None

Functions:

def greet(name):
    log("Hello,", name)
    return "Greeted!"

def add(a, b):
    return a + b

result = add(5, 3)

Conditionals:

if age > 18:
    log("Adult")
elif age > 13:
    log("Teenager")
else:
    log("Child")

Loops:

# For loop
for i in range(5):
    log("Count:", i)

# While loop
count = 0
while count < 5:
    log(count)
    count += 1

Lists:

fruits = ["apple", "banana", "orange"]
log(fruits[0])

fruits.append("grape")
log(fruits.length)

Dictionaries:

person = {
    "name": "Alice",
    "age": 30,
    "city": "NYC"
}

log(person["name"])
log(person.age)

Classes:

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    
    def greet(self):
        log(f"Hi, I'm {self.name}")
    
    def birthday(self):
        self.age += 1

p = Person("Bob", 25)
p.greet()

Import Node.js modules:

import "fs"
import "path" as pathModule

# Use Node.js modules directly!
content = fs.readFileSync("file.txt", "utf8")

String Formatting:

name = "World"
log(f"Hello, {name}!")
log(f"2 + 2 = {2 + 2}")

Try/Except:

try:
    risky_operation()
except error:
    log("Error:", error.message)
finally:
    log("Cleanup")

🎯 Examples

Fibonacci:

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n - 1) + fibonacci(n - 2)

for i in range(10):
    log(f"Fib({i}) = {fibonacci(i)}")

Simple Web Server:

import "http"

def handle_request(req, res):
    res.writeHead(200, {"Content-Type": "text/plain"})
    res.end("Hello from PyScript!")

server = http.createServer(handle_request)
server.listen(3000)
log("🐍 Server running on port 3000")

🔧 How It Works

PyScript transpiles Python-like syntax to JavaScript in real-time:

  1. Parses Python-style code
  2. Converts to equivalent JavaScript
  3. Executes in Node.js runtime

💡 Why PyScript?

  • Learn Python syntax while using Node.js ecosystem
  • Prototype quickly with Python's clean syntax
  • Bridge Python and JavaScript in your projects
  • Have fun with a unique programming experience

📧 Contact

📝 License

MIT License - Free to use in your projects!


Português

🐍 Sintaxe estilo Python rodando no Node.js. Sem necessidade de instalar Python!

PyScript é um transpilador que converte sintaxe estilo Python em JavaScript, permitindo que você escreva código com a sintaxe elegante do Python enquanto aproveita todo o ecossistema do Node.js.

✨ Recursos

  • 🎯 Sintaxe tipo Python - Escreva código que parece e se sente como Python
  • Roda no Node.js - Não precisa instalar Python
  • 🔄 Transpilação em tempo real - Converte seu código na hora
  • 📦 Fácil de usar - Interface CLI simples
  • 🎨 Mensagens de erro bonitas - Relatórios claros e úteis

🚀 Instalação

npm install -g pyscript-lang

Ou use localmente:

npm install pyscript-lang

📖 Começando

Linha de comando:

# Execute um arquivo PyScript
pyscript meuarquivo.pys

# Ou use o alias curto
pys meuarquivo.pys

Programático:

const PyScript = require('pyscript-lang');
const codigo = 'log("Olá do PyScript!")';
PyScript.run(codigo);

🎓 Guia de Sintaxe

Imprimir/Log:

log("Olá, Mundo!")
log("Valor:", 42, "Múltiplos", "argumentos")

Variáveis:

nome = "PyScript"
idade = 2
ativo = True
nada = None

Funções:

def saudar(nome):
    log("Olá,", nome)
    return "Saudado!"

def somar(a, b):
    return a + b

resultado = somar(5, 3)

Condicionais:

if idade > 18:
    log("Adulto")
elif idade > 13:
    log("Adolescente")
else:
    log("Criança")

Loops:

# Loop for
for i in range(5):
    log("Contagem:", i)

# Loop while
contador = 0
while contador < 5:
    log(contador)
    contador += 1

Listas:

frutas = ["maçã", "banana", "laranja"]
log(frutas[0])

frutas.append("uva")
log(frutas.length)

Dicionários:

pessoa = {
    "nome": "Alice",
    "idade": 30,
    "cidade": "SP"
}

log(pessoa["nome"])
log(pessoa.idade)

Classes:

class Pessoa:
    def __init__(self, nome, idade):
        self.nome = nome
        self.idade = idade
    
    def saudar(self):
        log(f"Oi, eu sou {self.nome}")
    
    def aniversario(self):
        self.idade += 1

p = Pessoa("Bob", 25)
p.saudar()

Importar módulos Node.js:

import "fs"
import "path" as moduloPath

# Use módulos Node.js diretamente!
conteudo = fs.readFileSync("arquivo.txt", "utf8")

Formatação de Strings:

nome = "Mundo"
log(f"Olá, {nome}!")
log(f"2 + 2 = {2 + 2}")

Try/Except:

try:
    operacao_arriscada()
except erro:
    log("Erro:", erro.message)
finally:
    log("Limpeza")

🎯 Exemplos

Fibonacci:

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n - 1) + fibonacci(n - 2)

for i in range(10):
    log(f"Fib({i}) = {fibonacci(i)}")

Servidor Web Simples:

import "http"

def processar_requisicao(req, res):
    res.writeHead(200, {"Content-Type": "text/plain"})
    res.end("Olá do PyScript!")

servidor = http.createServer(processar_requisicao)
servidor.listen(3000)
log("🐍 Servidor rodando na porta 3000")

🔧 Como Funciona

PyScript transpila sintaxe tipo Python para JavaScript em tempo real:

  1. Analisa o código estilo Python
  2. Converte para JavaScript equivalente
  3. Executa no runtime do Node.js

💡 Por Que PyScript?

  • Aprenda sintaxe Python usando o ecossistema Node.js
  • Prototipe rapidamente com a sintaxe limpa do Python
  • Una Python e JavaScript nos seus projetos
  • Divirta-se com uma experiência de programação única

📧 Contato

📝 Licença

Licença MIT - Livre para usar nos seus projetos!


Made with 💙 by capybarascript

Write Python, Run JavaScript 🐍