{ "info": { "author": "Mars Galactic", "author_email": "xoviat@users.noreply.github.com", "bugtrack_url": null, "classifiers": [], "description": "Introduction\n------------\n\nGython is a transpiler written in Python that converts a python like\nlanguage into Go.\n\n`Syntax\nDocumentation `__\n\nInstalling\n==========\n\nInstall using ``pip install gython``.\n\nUsage:\n\n::\n\n gython file.py\n\nGetting Started\n===============\n\nGython supports classes and multiple inheritance, with method overrides\nand calling the parent class methods.\n\n::\n\n class A:\n def foo(self) -> int:\n return 1\n\n class B:\n def bar(self) -> int:\n return 2\n\n class C( A, B ):\n def call_foo_bar(self) -> int:\n a = self.foo()\n a += self.bar()\n return a\n\n def foo(self) -> int:\n a = A.foo(self)\n a += 100\n return a\n\nGython supports Go's typed maps.\n\n::\n\n a = map[string]int{\n 'x': 1,\n 'y': 2,\n 'z': 3,\n }\n\nGython supports array and map comprehensions. Below is an array of\nintegers, and a map of strings with integer keys.\n\n::\n\n a = []int(x for x in range(3))\n b = map[int]string{ i:'xxx' for i in range(10) }\n\nGython supports Go's send data to channel syntax\n\n::\n\n a = go.channel( int )\n a <- 1\n\nArray and maps are always passed as pointers in a function call, this\nway the called function can modify the array or map inplace. In the\nexample below ``a`` is typed as an array of integers ``[]int``, but it\nis actually retyped when transformed into Go as ``*[]int``\n\n::\n\n def myfunc( a:[]int ):\n a.append( 100 )\n\n x = []int()\n myfunc( x )\n\nSimple Generator Functions\n==========================\n\nGython supports generator functions with a single for loop that yields\nfrom its main body. The generator function can also yield once before\nthe loop, and once after.\n\n::\n\n def fib(n:int) -> int:\n int a = 0\n int b = 1\n int c = 0\n for x in range(n):\n yield a\n c = b\n b = a+b\n a = c\n yield -1\n\n def main():\n arr = []int()\n for n in fib(20):\n arr.append( n )\n\nGeneric High Order Functions\n============================\n\nGython supports generic functions, where the first argument can be an\ninstance of different subclasses. All the subclasses must share the same\ncommon base class. In the function definition the first argument is\ntyped with the name of the common base class. In the function below\n``my_generic``, the first argument ``g`` is typed with the common base\nclass: ``def my_generic( a:A )``\n\n::\n\n class A:\n def __init__(self, x:int):\n int self.x = x\n\n def method1(self) -> int:\n return self.x\n\n class B(A):\n\n def method1(self) ->int:\n return self.x * 2\n\n class C(A):\n\n def method1(self) ->int:\n return self.x + 200\n\n\n def my_generic( g:A ) ->int:\n return g.method1()\n\n def main():\n a = A( 100 )\n b = B( 100 )\n c = C( 100 )\n\n x = my_generic( a )\n a.x == x\n\n y = my_generic( b )\n y==200\n\n z = my_generic( c )\n z==300\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/xoviat/gython", "keywords": "", "license": "### GNU GENERAL PUBLIC LICENSE", "maintainer": "", "maintainer_email": "", "name": "gython", "package_url": "https://pypi.org/project/gython/", "platform": "any", "project_url": "https://pypi.org/project/gython/", "project_urls": { "Homepage": "https://github.com/xoviat/gython" }, "release_url": "https://pypi.org/project/gython/0.9.9/", "requires_dist": null, "requires_python": "", "summary": "Python to go transpiler", "version": "0.9.9" }, "last_serial": 3646410, "releases": { "0.9.8": [ { "comment_text": "", "digests": { "md5": "f9120f75f46123228e1b56396b09723c", "sha256": "818a9f9dc211090d3936fb02cc82bc3d0d40cc8e676023f319790f5a1720bc4c" }, "downloads": -1, "filename": "gython-0.9.8-py3-none-any.whl", "has_sig": false, "md5_digest": "f9120f75f46123228e1b56396b09723c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 91433, "upload_time": "2017-04-29T05:19:07", "url": "https://files.pythonhosted.org/packages/a9/df/a0a2061b59f57a3505d19063f8fd18ce61819c8fbd34241f0888f1e2e5f1/gython-0.9.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d7b7a5e87845e1c4f673127b44f298ba", "sha256": "29cb2d48196cbfad154373f9cb9a8220bd40a876d161903f74cec2fd842e6b9a" }, "downloads": -1, "filename": "gython-0.9.8.tar.gz", "has_sig": false, "md5_digest": "d7b7a5e87845e1c4f673127b44f298ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 107077, "upload_time": "2017-04-29T05:19:08", "url": "https://files.pythonhosted.org/packages/dc/f3/68fc338f9456d9637712ad53d6b2fdeb79d8f51186a03e55c3c5fcd277b5/gython-0.9.8.tar.gz" } ], "0.9.9": [ { "comment_text": "", "digests": { "md5": "1dbced1e1ab9b4284f00d2fe519dcd05", "sha256": "c7430b4e6d4d5ae59bec925310a4ce861f536c5afddee4add8f508407e59006c" }, "downloads": -1, "filename": "gython-0.9.9-py3-none-any.whl", "has_sig": false, "md5_digest": "1dbced1e1ab9b4284f00d2fe519dcd05", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 91159, "upload_time": "2017-04-29T17:01:44", "url": "https://files.pythonhosted.org/packages/f4/5e/4e4b0a200d38ae7be8abb92e2359324feeadd7e87eba4e9ed8fa02da938d/gython-0.9.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aaad3ede1aa900cf9d2c8f8adf0dd482", "sha256": "1f5987179735d80548d5ff09e33e3ec371b04e3e3dd536a1fafef2410256a0fd" }, "downloads": -1, "filename": "gython-0.9.9.tar.gz", "has_sig": false, "md5_digest": "aaad3ede1aa900cf9d2c8f8adf0dd482", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 106820, "upload_time": "2017-04-29T17:01:47", "url": "https://files.pythonhosted.org/packages/2b/b6/28714caa46d3d08f98b8b0a3fe7b1959a67c6488986d5c6662a87b520ab4/gython-0.9.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1dbced1e1ab9b4284f00d2fe519dcd05", "sha256": "c7430b4e6d4d5ae59bec925310a4ce861f536c5afddee4add8f508407e59006c" }, "downloads": -1, "filename": "gython-0.9.9-py3-none-any.whl", "has_sig": false, "md5_digest": "1dbced1e1ab9b4284f00d2fe519dcd05", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 91159, "upload_time": "2017-04-29T17:01:44", "url": "https://files.pythonhosted.org/packages/f4/5e/4e4b0a200d38ae7be8abb92e2359324feeadd7e87eba4e9ed8fa02da938d/gython-0.9.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aaad3ede1aa900cf9d2c8f8adf0dd482", "sha256": "1f5987179735d80548d5ff09e33e3ec371b04e3e3dd536a1fafef2410256a0fd" }, "downloads": -1, "filename": "gython-0.9.9.tar.gz", "has_sig": false, "md5_digest": "aaad3ede1aa900cf9d2c8f8adf0dd482", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 106820, "upload_time": "2017-04-29T17:01:47", "url": "https://files.pythonhosted.org/packages/2b/b6/28714caa46d3d08f98b8b0a3fe7b1959a67c6488986d5c6662a87b520ab4/gython-0.9.9.tar.gz" } ] }