{ "info": { "author": "Gerald Klix", "author_email": "gf@klix.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Python Software Foundation License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation", "Topic :: Software Development :: Libraries" ], "description": "=============================================\nGF3: Lisp-Like Generic Functions For Python 3\n=============================================\n\nOverview\n========\n\n`gf` lets you write generic functions\n`generic functions `_\nwith multi-methods, that dispatch on all their arguments.\n\nSimple Example\n--------------\n\n>>> from gf import generic, method\n>>> add = generic()\n>>> type(add)\n\n\nLets define `add` for two integers:\n\n>>> @method()\n... def add(n0: int, n1: int):\n... return n0 + n1\n\nLets test it:\n\n>>> add(1, 2)\n3\n\nCalling `add` with instances of other types fails:\n\n>>> add(\"Hello \", \"World\")\nTraceback (most recent call last):\n...\nNotImplementedError: Generic '__main__.add' has no implementation for type(s): __builtin__.str, __builtin__.str\n\nOf course `add` can also by defined for two strings:\n\n>>> @method()\n... def add(s0: str, s1: str):\n... return s0 + s1\n\nNow our hello world example works:\n\n>>> add(\"Hello \", \"World\")\n'Hello World'\n\n`add` can also be defined for a string and an integer:\n\n>>> @method()\n... def add(s: str, n: int):\n... return s + str(n)\n\nThus we can add a string and a number:\n\n>>> add(\"You \", 2)\n'You 2'\n\nPython's Special Methods\n------------------------\n\n`gf.Object` implements (nearly) all of the `special instance\nmethods of a python object`_ as a generic function.\nThe package includes a rational number implementation that makes\nheavy use of this feature:\n\n.. code:: python\n\n @method()\n def __add__(a: object, b: Rational):\n \"\"\"Add an object and a rational number.\n\n `a` is converted to a `Rational` and then both are added.\"\"\"\n return Rational(a) + b\n\n @method(Rational, object)\n def __add__(a: Rational, b: object):\n \"\"\"Add a rational number and an object.\n\n `b` is converted to a `Rational` and then both are added.\"\"\"\n return a + Rational(b)\n\n`gf.Object` also has a more Smalltalk means of overwriting\n`object.__str__` and `object.__repr__` using a file like object.\nAgain the rational example is instructive about its usage.\n\n.. code:: python\n\n @method()\n def __out__(rational: Rational, writer: Writer):\n \"\"\"Write a nice representation of the rational.\n\n Denominators that equal 1 are not printed.\"\"\"\n writer(\"%d\", rational.numerator)\n if rational.denominator != 1:\n writer(\" / %d\", rational.denominator)\n\n @method()\n def __spy__(rational: Rational, writer: Writer):\n \"\"\"Write a debug representation of the rational.\"\"\"\n writer(\"%s(\", rational.__class__.__name__)\n if rational.numerator != 0:\n writer(\"%r\", rational.numerator)\n if rational.denominator != 1:\n writer(\", %r\", rational.denominator)\n writer(\")\")\n\n.. _special instance methods of a python object:\n http://docs.python.org/2/reference/datamodel.html#special-method-names\n\n\nInstallation\n------------\n\nAs usual `gf3` can be installed with `pip`, like this:\n\n pip install gf3\n\nDocumentation\n-------------\n\nThe whole documentation is available at in the following formats\n\n HTML\n http://gf3.klix.ch (Also servers as `gf`'s homepage)\n\n PDF\n http://gf3.klix.ch/gf3.pdf\n\nChanges\n-------\n\nA short sketch of the changes done in each release.\n\nRelease 0.2.4\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.2.4:\n\n * The `push`-method accepts an identation string\n for identing writers.\n * The methods `push` and `pop` now accept\n arbitrary arguments in the general case.\n * Successfully tested the whole framework with Python 3.5.\n\n\nRelease 0.2.3\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.2.3:\n\n * Fixed the long description.\n * Wrote some documentation about changing the implementation\n class of a generic function.\n\n\nRelease 0.2.2\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.2.2:\n\n * Write more documentation.\n Especially documented the `merge` and the `isgeneric`\n functions.\n * Consistency between the long text and on PyPi and the documentation.\n\n\nRelease 0.2.1\n~~~~~~~~~~~~~\n\nNeeded to bump the version information, because the homepage\nin the package-information was wrong [#]_ and a new upload was needed.\n\n\nRelease 0.2.0\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.2.0:\n\n * Ported the whole module to Python 3.6 and Python 3.7.\n * Exclusively uses `parameter annotations`_ to specify the types to dispatch on.\n * Added standard conforming default implementations for methods\n like `__add__`. All these methods now raise a proper\n `TypeError` instead of raising a `NotImplementedError`.\n * Added some means to write generic functions that dispatch types only.\n This is the generic function equivalent of a class-method.\n * Added some means to dispatch on single objects.\n This is the equivalent adding methods to class-instances [#]_.\n * The package name for PyPi is now ``gf3``.\n\n.. _parameter annotations: https://docs.python.org/3/reference/compound_stmts.html#grammar-token-parameter\n\n\nRelease 0.1.4\n~~~~~~~~~~~~~\n\nThe following was fixed in Release 0.1.4:\n\n * Fixed an issue with variadic methods. Sometimes definitions\n of variadic methods added after the method was already called\n where not added.\n * Specified and implemented a precedence rule for overlapping\n variadic methods of generic functions.\n * Improved generated documentation for variadic methods.\n * Fixed the markup of some notes in the documentation.\n\n\nRelease 0.1.3\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.1.3:\n\n * Added variadic methods, e.g. multi-methods with a\n variable number of arguments.\n * Improved the long description text a bit\n and fixed bug in its markup.\n * Fixed invalid references in the long description.\n\n\nRelease 0.1.2\n~~~~~~~~~~~~~\n\nThe following was changed in Release 0.1.2:\n\n * Added a generic functions for `gf.Object.__call__`.\n * Added a `gf.go.FinalizingMixin`.\n * `gf.generic` now also accepts a type.\n * Improved the exception information for ambiguous calls.\n * Fixed some documentation glitches.\n\n\nRelease 0.1.1\n~~~~~~~~~~~~~\n\nThis was the initial release.\n\n.. [#] Silly me discovered about the shutdown of pythonhosted.org\n after version 0.2.0 was uploaded.\n.. [#] Of course this is not possible with standard python classes\n and their instances.\n\nAcknowledgements\n================\n\nGuido van Rossum created the core of this package. I just renamed some things\nand added some^H^H^H^H oodles of convenience stuff. Thank you Guido!\n\n\nCopyright\n=========\n\n\u00a9 2006-2013 Python Software Foundation.\n\u00a9 2013-2018 Gerald Klix.", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://gf3.klix.ch/", "keywords": "generic-function multi-method", "license": "PSF", "maintainer": "", "maintainer_email": "", "name": "gf3", "package_url": "https://pypi.org/project/gf3/", "platform": "", "project_url": "https://pypi.org/project/gf3/", "project_urls": { "Homepage": "http://gf3.klix.ch/" }, "release_url": "https://pypi.org/project/gf3/0.2.4/", "requires_dist": null, "requires_python": "", "summary": "A package with lisp-like generic functions for python 3.", "version": "0.2.4" }, "last_serial": 5641318, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "4d83fb54039a1c8fdf9b53100c6aae40", "sha256": "983d43c3214268b99a199aa265e57ad7fc8b73d62f54b037cae6f2d814eaa83a" }, "downloads": -1, "filename": "gf3-0.2.1.tar.gz", "has_sig": false, "md5_digest": "4d83fb54039a1c8fdf9b53100c6aae40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30836, "upload_time": "2018-09-29T18:16:15", "url": "https://files.pythonhosted.org/packages/b4/5d/9b331efb9f8c069031d15e937c9defb40ae4aee983d27e84257e14db49fa/gf3-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "2bb7dcf07905ea65da2971cf13d828bc", "sha256": "a8108c2ea33b39f8dc4354d8bef42a035da99ed271a442ac7a650035ae4aa013" }, "downloads": -1, "filename": "gf3-0.2.2.tar.gz", "has_sig": false, "md5_digest": "2bb7dcf07905ea65da2971cf13d828bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32264, "upload_time": "2018-09-30T13:03:11", "url": "https://files.pythonhosted.org/packages/41/66/e70d94e09b7a657d886799aec4083a15904d3d3265267b499f566c4f62c3/gf3-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "5ca7f7faae528aa21b27deccf3bff896", "sha256": "a31c64aee81d22a48893fff69f67381fd751fed2fffd6c0f6b3395d610909865" }, "downloads": -1, "filename": "gf3-0.2.3.tar.gz", "has_sig": false, "md5_digest": "5ca7f7faae528aa21b27deccf3bff896", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32911, "upload_time": "2018-09-30T13:57:08", "url": "https://files.pythonhosted.org/packages/e7/30/8392561c8498531a8e6d33e585f736432b3ffde5301e7999708af011326f/gf3-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "e9c6fa3dd525ae2ab03ec1f6d05315cc", "sha256": "08ee61cd016eb4bc5fe606ea95add2b5601ae12e0aa6ee6b28be706057f5b500" }, "downloads": -1, "filename": "gf3-0.2.4.tar.gz", "has_sig": false, "md5_digest": "e9c6fa3dd525ae2ab03ec1f6d05315cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33413, "upload_time": "2019-08-06T19:33:44", "url": "https://files.pythonhosted.org/packages/13/e9/6cbd72d6fd8fa6e4ba0f74608c6cd160cc92d47ad56ea1eb36c173226196/gf3-0.2.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e9c6fa3dd525ae2ab03ec1f6d05315cc", "sha256": "08ee61cd016eb4bc5fe606ea95add2b5601ae12e0aa6ee6b28be706057f5b500" }, "downloads": -1, "filename": "gf3-0.2.4.tar.gz", "has_sig": false, "md5_digest": "e9c6fa3dd525ae2ab03ec1f6d05315cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33413, "upload_time": "2019-08-06T19:33:44", "url": "https://files.pythonhosted.org/packages/13/e9/6cbd72d6fd8fa6e4ba0f74608c6cd160cc92d47ad56ea1eb36c173226196/gf3-0.2.4.tar.gz" } ] }