https://github.com/go-python/gotopy
Go to Python converter -- translates Go code into Python code
https://github.com/go-python/gotopy
converter go golang python translation
Last synced: 2 months ago
JSON representation
Go to Python converter -- translates Go code into Python code
- Host: GitHub
- URL: https://github.com/go-python/gotopy
- Owner: go-python
- License: bsd-3-clause
- Fork: true (goki/gotopy)
- Created: 2020-10-26T00:05:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-26T17:31:25.000Z (over 4 years ago)
- Last Synced: 2024-06-19T02:01:45.948Z (almost 2 years ago)
- Topics: converter, go, golang, python, translation
- Language: Go
- Homepage:
- Size: 180 KB
- Stars: 34
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoToPy
GoToPy is a Go to Python converter -- translates Go code into Python code.
To install, do standard:
```Go
$ go install github.com/go-python/gotopy@latest
```
It is based on the Go `gofmt` command source code and the go `printer` package, which parses Go files and writes them out according to standard go formatting.
We have modified the `printer` code in the `pyprint` package to instead print out Python code.
The `-gopy` flag generates [GoPy](https:://github.com/go-python/gopy) specific Python code, including:
* `nil` -> `go.nil`
* `[]string{...}` -> `go.Slice_string([...])` etc for int, float64, float32
The `-gogi` flag generates [GoGi](https:://github.com/goki/gi) specific Python code, including:
* struct tags generate: `self.SetTags()` call, for the `pygiv.ClassViewObj` class, which then provides an automatic GUI view with tag-based formatting of struct fields.
# TODO
* switch -> ifs.. -- grab switch expr and put into each if
* string .contains -> "el" in str
* map access with 2 vars = if el in map: mv = map[el]
* for range with 2 vars = enumerate(slice)