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



Write Python, Execute JavaScript
---
> 🐍 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.
- 🎯 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
``bash`
npm install -g pyscript-lang
Or use it locally:
`bash`
npm install pyscript-lang
Command Line:
`bashRun a PyScript file
pyscript myfile.pys
Programmatic:
`javascript
const PyScript = require('pyscript-lang');
const code = 'log("Hello from PyScript!")';
PyScript.run(code);
`$3
Print/Log:
`python
log("Hello, World!")
log("Value:", 42, "Multiple", "arguments")
`Variables:
`python
name = "PyScript"
age = 2
active = True
nothing = None
`Functions:
`python
def greet(name):
log("Hello,", name)
return "Greeted!"def add(a, b):
return a + b
result = add(5, 3)
`Conditionals:
`python
if age > 18:
log("Adult")
elif age > 13:
log("Teenager")
else:
log("Child")
`Loops:
`python
For loop
for i in range(5):
log("Count:", i)While loop
count = 0
while count < 5:
log(count)
count += 1
`Lists:
`python
fruits = ["apple", "banana", "orange"]
log(fruits[0])fruits.append("grape")
log(fruits.length)
`Dictionaries:
`python
person = {
"name": "Alice",
"age": 30,
"city": "NYC"
}log(person["name"])
log(person.age)
`Classes:
`python
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 += 1p = Person("Bob", 25)
p.greet()
`Import Node.js modules:
`python
import "fs"
import "path" as pathModuleUse Node.js modules directly!
content = fs.readFileSync("file.txt", "utf8")
`String Formatting:
`python
name = "World"
log(f"Hello, {name}!")
log(f"2 + 2 = {2 + 2}")
`Try/Except:
`python
try:
risky_operation()
except error:
log("Error:", error.message)
finally:
log("Cleanup")
`$3
Fibonacci:
`python
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:
`python
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")
`$3
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
$3
- 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
$3
- Author: capybarascript
- Email: capybaraconpany@gmail.com
- npm: npmjs.com/package/pyscript-lang
$3
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.
$3
- 🎯 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
$3
`bash
npm install -g pyscript-lang
`Ou use localmente:
`bash
npm install pyscript-lang
`$3
Linha de comando:
`bash
Execute um arquivo PyScript
pyscript meuarquivo.pysOu use o alias curto
pys meuarquivo.pys
`Programático:
`javascript
const PyScript = require('pyscript-lang');
const codigo = 'log("Olá do PyScript!")';
PyScript.run(codigo);
`$3
Imprimir/Log:
`python
log("Olá, Mundo!")
log("Valor:", 42, "Múltiplos", "argumentos")
`Variáveis:
`python
nome = "PyScript"
idade = 2
ativo = True
nada = None
`Funções:
`python
def saudar(nome):
log("Olá,", nome)
return "Saudado!"def somar(a, b):
return a + b
resultado = somar(5, 3)
`Condicionais:
`python
if idade > 18:
log("Adulto")
elif idade > 13:
log("Adolescente")
else:
log("Criança")
`Loops:
`python
Loop for
for i in range(5):
log("Contagem:", i)Loop while
contador = 0
while contador < 5:
log(contador)
contador += 1
`Listas:
`python
frutas = ["maçã", "banana", "laranja"]
log(frutas[0])frutas.append("uva")
log(frutas.length)
`Dicionários:
`python
pessoa = {
"nome": "Alice",
"idade": 30,
"cidade": "SP"
}log(pessoa["nome"])
log(pessoa.idade)
`Classes:
`python
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 += 1p = Pessoa("Bob", 25)
p.saudar()
`Importar módulos Node.js:
`python
import "fs"
import "path" as moduloPathUse módulos Node.js diretamente!
conteudo = fs.readFileSync("arquivo.txt", "utf8")
`Formatação de Strings:
`python
nome = "Mundo"
log(f"Olá, {nome}!")
log(f"2 + 2 = {2 + 2}")
`Try/Except:
`python
try:
operacao_arriscada()
except erro:
log("Erro:", erro.message)
finally:
log("Limpeza")
`$3
Fibonacci:
`python
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:
`python
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")
``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
- 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
- Autor: capybarascript
- Email: capybaraconpany@gmail.com
- npm: npmjs.com/package/pyscript-lang
Licença MIT - Livre para usar nos seus projetos!
---
Made with 💙 by capybarascript
Write Python, Run JavaScript 🐍