{"id":15400950,"url":"https://github.com/pwaller/pp2g","last_synced_at":"2026-04-28T08:39:11.514Z","repository":{"id":139233146,"uuid":"61430942","full_name":"pwaller/pp2g","owner":"pwaller","description":"Crude python to go translator","archived":false,"fork":false,"pushed_at":"2018-10-04T09:31:55.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T02:28:07.924Z","etag":null,"topics":["go","python","python-to-go","transpilation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwaller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-18T11:44:03.000Z","updated_at":"2019-05-23T00:30:00.000Z","dependencies_parsed_at":"2024-04-19T04:01:03.978Z","dependency_job_id":null,"html_url":"https://github.com/pwaller/pp2g","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwaller%2Fpp2g","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwaller%2Fpp2g/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwaller%2Fpp2g/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwaller%2Fpp2g/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwaller","download_url":"https://codeload.github.com/pwaller/pp2g/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245949436,"owners_count":20698914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","python","python-to-go","transpilation"],"created_at":"2024-10-01T15:55:44.810Z","updated_at":"2026-04-28T08:39:06.467Z","avatar_url":"https://github.com/pwaller.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pp2g: print python to go\n\nThis is a (currently incomplete and abandoned) experiment to assist in translating python to Go. The goal is not to do a perfect job, but enough that a human can come in and translate it to standalone idiomatic Go.\n\n### You might also like\n\n* [pytogo](https://gitlab.com/esr/pytogo), which takes a similar approach, though it works with lots of regexes rather than parsing the AST.\n* [grumpy](https://github.com/google/grumpy) an effort by a Google engineer to translate some code which runs Youtube from Python to Go. As I understand it, it produces runnable code, but it isn't idiomatic or standalone, and implements lots of Python.\n* [gython](https://github.com/gython/Gython) which describes itself as \"a transpiler written in Python that converts a python like language into Go\".\n\n### About\n\nThe method it takes is essentially to pretty print the python AST. The only reason it doesn't do this from Go is that there wasn't a python parser written in Go at the time and I wasn't in the mood for writing one :)\n\nTo give you a feel of it, this is how it currently translates [`bisect.py`](https://github.com/python/cpython/blob/5f5a7781c8bf7bcc476d3e05d980711be3920724/Lib/bisect.py) from the standard library. You'll note that some constructs aren't yet translated, such as while loops and try blocks. Everything is translated into a comment so that it can be used as a guide.\n\n```go\npackage bisect\n\n\"Bisection algorithms.\"\n\n// Insert item x in list a, and keep it sorted assuming a is sorted.\n// \n//     If x is already in a, insert it to the right of the rightmost x.\n// \n//     Optional args lo (default 0) and hi (default len(a)) bound the\n//     slice of a to be searched.\nfunc InsortRight(a python.Type, x python.Type, lo python.Type, hi python.Type) {\n\t// if lo \u003c 0 {\n\t// \t// unknown Raise('exc', 'cause')\n\t// }\n\t// if hi is None {\n\t// \thi = len(a)\n\t// }\n\t// // unknown While('test', 'body', 'orelse')\n\t// a.insert(lo, x)\n}\nvar insort = insortRight\n\n// Return the index where to insert item x in list a, assuming a is sorted.\n// \n//     The return value i is such that all e in a[:i] have e \u003c= x, and all e in\n//     a[i:] have e \u003e x.  So if x already appears in the list, a.insert(x) will\n//     insert just after the rightmost x already there.\n// \n//     Optional args lo (default 0) and hi (default len(a)) bound the\n//     slice of a to be searched.\nfunc BisectRight(a python.Type, x python.Type, lo python.Type, hi python.Type) {\n\t// if lo \u003c 0 {\n\t// \t// unknown Raise('exc', 'cause')\n\t// }\n\t// if hi is None {\n\t// \thi = len(a)\n\t// }\n\t// // unknown While('test', 'body', 'orelse')\n\t// return lo\n}\nvar bisect = bisectRight\n\n// Insert item x in list a, and keep it sorted assuming a is sorted.\n// \n//     If x is already in a, insert it to the left of the leftmost x.\n// \n//     Optional args lo (default 0) and hi (default len(a)) bound the\n//     slice of a to be searched.\nfunc InsortLeft(a python.Type, x python.Type, lo python.Type, hi python.Type) {\n\t// if lo \u003c 0 {\n\t// \t// unknown Raise('exc', 'cause')\n\t// }\n\t// if hi is None {\n\t// \thi = len(a)\n\t// }\n\t// // unknown While('test', 'body', 'orelse')\n\t// a.insert(lo, x)\n}\n\n// Return the index where to insert item x in list a, assuming a is sorted.\n// \n//     The return value i is such that all e in a[:i] have e \u003c x, and all e in\n//     a[i:] have e \u003e= x.  So if x already appears in the list, a.insert(x) will\n//     insert just before the leftmost x already there.\n// \n//     Optional args lo (default 0) and hi (default len(a)) bound the\n//     slice of a to be searched.\nfunc BisectLeft(a python.Type, x python.Type, lo python.Type, hi python.Type) {\n\t// if lo \u003c 0 {\n\t// \t// unknown Raise('exc', 'cause')\n\t// }\n\t// if hi is None {\n\t// \thi = len(a)\n\t// }\n\t// // unknown While('test', 'body', 'orelse')\n\t// return lo\n}\n// unknown Try('body', 'handlers', 'orelse', 'finalbody')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwaller%2Fpp2g","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwaller%2Fpp2g","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwaller%2Fpp2g/lists"}