Projetos
Ver no GitHub
nottheswimmer/pytago
Sobre
A source-to-source transpiler for Python to Go translation
Linguagens e ambientes de execuçãoCrescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- 0
- em 15 dias
- 0
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalPytago is a source-to-source transpiler that converts some Python into human-readable Go.
Installation and usage
There are two "officially" supported ways to use Pytago:
- A web application you can run via docker
- A locally-installed command-line tool
Web application
Prerequisites
Installation and Usage
Running pre-built container
docker run -p 8080:8080 -e PORT=8080 -it nottheswimmer/pytago
Building from source (Alternative)
git clone https://github.com/nottheswimmer/pytago/
cd pytago
docker build -t pytago .
docker run -p 8080:8080 -e PORT=8080 -it pytago
Usage
# Open the user interface
open http://127.0.0.1:8080/
# API
curl --request POST 'http://127.0.0.1:8080/' \
--header 'Content-Type: application/json' \
--data-raw '{"py": "print(\"Hello World\")"}'
Local command-line application
Prerequisites
- Go 1.18.x
- Python 3.10.x
- No, it will not work on 3.9 due to the (heavy) usage of match statements.
- Required libraries for post-processing:
go install golang.org/x/tools/cmd/goimports@latest go install mvdan.cc/gofumpt@latest go install github.com/segmentio/golines@latest export PATH="$PATH:$HOME/go/bin"
Installation
via pip
pip install pytago
via setup.py (dev)
git clone https://github.com/nottheswimmer/pytago/
cd pytago
pip install -e .
via setup.py
git clone https://github.com/nottheswimmer/pytago/
cd pytago
pip install .
Usage
usage: pytago [-h] [-o OUTFILE] INFILE
positional arguments:
INFILE read python code from INFILE
options:
-h, --help show this help message and exit
-o OUTFILE, --out OUTFILE
write go code to OUTFILE
Examples
All examples presented here are used as tests for the program.
listappend
| Python | Go |
|---|---|
|
|
abs
| Python | Go |
|---|---|
|
|
helloworld
| Python | Go |
|---|---|
|
|
input
| Python | Go |
|---|---|
|
|
randomness
| Python | Go |
|---|---|
|
|
string_methods
| Python | Go |
|---|---|
|
|
list_methods
| Python | Go |
|---|---|
|
|
set_methods
| Python | Go |
|---|---|
|
|
global_code
| Python | Go |
|---|---|
|
|
boolnumcompare
| Python | Go |
|---|---|
|
|
add
| Python | Go |
|---|---|
|
|
exponents
| Python | Go |
|---|---|
|
|
variables
| Python | Go |
|---|---|
|
|
floats
| Python | Go |
|---|---|
|
|
numlist
| Python | Go |
|---|---|
|
|
loops
| Python | Go |
|---|---|
|
|
strings
| Python | Go |
|---|---|
|
|
logical
| Python | Go |
|---|---|
|
|
maths
| Python | Go |
|---|---|
|
|
requestslib
| Python | Go |
|---|---|
|
|
conditionals
| Python | Go |
|---|---|
|
|
fstrings
| Python | Go |
|---|---|
|
|
nestedfstrings
| Python | Go |
|---|---|
|
|
dictionary
| Python | Go |
|---|---|
|
|
writefile
| Python | Go |
|---|---|
|
|
pass
| Python | Go |
|---|---|
|
|
ellipsis
| Python | Go |
|---|---|
|
|
missingreturntype
| Python | Go |
|---|---|
|
|
continuestmt
| Python | Go |
|---|---|
|
|
breakstmt
| Python | Go |
|---|---|
|
|
whileloop
| Python | Go |
|---|---|
|
|
sets
| Python | Go |
|---|---|
|
|
contains
| Python | Go |
|---|---|
|
|
tryexcept
| Python | Go |
|---|---|
|
|
tryfinally
| Python | Go |
|---|---|
|
|
asserts
| Python | Go |
|---|---|
|
|
classes
| Python | Go |
|---|---|
|
|
globals
| Python | Go |
|---|---|
|
|
asyncawait
| Python | Go |
|---|---|
|
|
yields
| Python | Go |
|---|---|
|
|
isvseql
| Python | Go |
|---|---|
|
|
matchcase
| Python | Go |
|---|---|
|
|
defaultargs
| Python | Go |
|---|---|
|
|
walrus
| Python | Go |
|---|---|
|
|
truthiness
| Python | Go |
|---|---|
|
|
minmax
| Python | Go |
|---|---|
|
|
sum
| Python | Go |
|---|---|
|
|
reverse
| Python | Go |
|---|---|
|
|
listcomp
| Python | Go |
|---|---|
|
|
dictcomp
| Python | Go |
|---|---|
|
|
setcomp
| Python | Go |
|---|---|
|
|
generatorexp
| Python | Go |
|---|---|
|
|
ternary
| Python | Go |
|---|---|
|
|
isinstance
| Python | Go |
|---|---|
|
|
zip
| Python | Go |
|---|---|
|
|
map
| Python | Go |
|---|---|
|
|
repr
| Python | Go |
|---|---|
|
|
lambdafunc
| Python | Go |
|---|---|
|
|
timemodule
| Python | Go |
|---|---|
|
|
exit
| Python | Go |
|---|---|
|
|
retroactive_composite_types
| Python | Go |
|---|---|
|
|
isinstance_gives_type_assertion
| Python | Go |
|---|---|
|
|
fileloop
| Python | Go |
|---|---|
|
|
unpacking
| Python | Go |
|---|---|
|
|
cast_to_float
| Python | Go |
|---|---|
|
|
jsondump
| Python | Go |
|---|---|
|
|
strdunder
| Python | Go |
|---|---|
|
|
globfiles
| Python | Go |
|---|---|
|
|
stringmultiply
| Python | Go |
|---|---|
|
|
scope
| Python | Go |
|---|---|
|
|
forelse
| Python | Go |
|---|---|
|
|
slicemultiply
| Python | Go |
|---|---|
|
|
printend
| Python | Go |
|---|---|
|
|
structdunders
| Python | Go |
|---|---|
|
|
algomajorityelement
| Python | Go |
|---|---|
|
|
algobisection
| Python | Go |
|---|---|
|
|
algointersection
| Python | Go |
|---|---|
|
|
bitwisenot
| Python | Go |
|---|---|
|
|
index
| Python | Go |
|---|---|
|
|
timecode
| Python | Go |
|---|---|
|
|
typecall
| Python | Go |
|---|---|
|
|
TODOs
Some things I'd like to add soon...
- "value in range(start, stop, step)" => a conditional statement
- Exhaustive implementation of list/dict/int/float/bytes methods
Explore projetos relacionados
Carregando…