{ "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 :: 2.5", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2 :: Only", "Programming Language :: Python :: Implementation", "Topic :: Software Development :: Libraries" ], "description": "===============================\nGF: Lisp-Like generic Functions\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\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(int, int)\n... def add(n0, n1):\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(basestring, basestring)\n... def add(s0, s1):\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(basestring, int)\n... def add(s, n):\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(object, Rational)\n def __add__(a, b):\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, b):\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(Rational, Writer)\n def __out__(rational, 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(Rational, Writer)\n def __spy__(rational, 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\nChanges\n-------\n\nA short sketch of the changes done in each release.\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\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\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\nRelease 0.1.1\n~~~~~~~~~~~~~\n\nThis was the initial release.\n\nAcknowledgements\n================\nGuido van Rossum created the core of this package. I just renamed some things\nand added some convenience stuff. Thank you Guido!\n\nCopyright\n=========\n\u00a9 2006 Python Software Foundation.\n\u00a9 2006-2013 Gerald Klix.", "description_content_type": null, "docs_url": "https://pythonhosted.org/gf/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/gf", "keywords": "generic-function multi-method", "license": "PSF", "maintainer": null, "maintainer_email": null, "name": "gf", "package_url": "https://pypi.org/project/gf/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gf/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/gf" }, "release_url": "https://pypi.org/project/gf/0.1.4/", "requires_dist": null, "requires_python": null, "summary": "A package with lisp-like generic functions.", "version": "0.1.4" }, "last_serial": 948974, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "5f10ad738e01a12a4fee8a8b3d57f267", "sha256": "f1e9ab17955548946a9761efdbbd77ae37acc60409e603ed3df6eccd2aa27812" }, "downloads": -1, "filename": "gf-0.1.1-py2.7.egg", "has_sig": false, "md5_digest": "5f10ad738e01a12a4fee8a8b3d57f267", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 30814, "upload_time": "2013-05-11T12:45:23", "url": "https://files.pythonhosted.org/packages/5e/f4/9d667389426c2c8f96ea0a0a3de10b5bd166c8ce8b624c13d8e5f5b0f1d8/gf-0.1.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "a2cf7a970d007605aedcca93b27e970c", "sha256": "266a1893ebbe923e356b2e9f96e094a9ed33b398160359088431e04e04b635af" }, "downloads": -1, "filename": "gf-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a2cf7a970d007605aedcca93b27e970c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18758, "upload_time": "2013-05-11T12:45:08", "url": "https://files.pythonhosted.org/packages/b9/72/a8991367435e2f01751dbdbc131eac9bf08fb88aec69ecc367186c8b7d6c/gf-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "7ad635e447e2f28390b98e08fa7a0295", "sha256": "43af33ba5520c5a0103f161641bdd333de0fdbbb26720250894100ba1c35635f" }, "downloads": -1, "filename": "gf-0.1.2-py2.7.egg", "has_sig": false, "md5_digest": "7ad635e447e2f28390b98e08fa7a0295", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 31640, "upload_time": "2013-08-20T20:08:42", "url": "https://files.pythonhosted.org/packages/83/6f/e0beae6447ef6dee7a196b431870113b6b155c3e2bc3ecb32a7c1a2531ed/gf-0.1.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "f0d8e883b25433fcb5c9539df028a71a", "sha256": "72174da854b52123f6bc088a382496b439816aede76faf6fb830b4f213429ed7" }, "downloads": -1, "filename": "gf-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f0d8e883b25433fcb5c9539df028a71a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19645, "upload_time": "2013-08-20T20:08:33", "url": "https://files.pythonhosted.org/packages/3b/ac/10131c4eccc1de41b06984e68acb7cfab8bfb3292a66205d31f04844c04d/gf-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8079dc1481055ac7a69f16587538012e", "sha256": "2f2917488062f7abcdc60ffd51c7f8a4f5416c90adf3f5622994a51cdcc0ef4b" }, "downloads": -1, "filename": "gf-0.1.3-py2.7.egg", "has_sig": false, "md5_digest": "8079dc1481055ac7a69f16587538012e", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 33360, "upload_time": "2013-08-23T12:22:09", "url": "https://files.pythonhosted.org/packages/21/f9/61f82a3228df55600eddad5e0ae82566544464566b62dba69415880e4136/gf-0.1.3-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "595a2ed86a9d3b85d2c4b6153ebb23fb", "sha256": "5980d2dac7ca04c3c5e1c91342adcba5872f0ce542f999c1e6c779ec95686e4f" }, "downloads": -1, "filename": "gf-0.1.3.tar.gz", "has_sig": false, "md5_digest": "595a2ed86a9d3b85d2c4b6153ebb23fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21664, "upload_time": "2013-08-23T12:22:05", "url": "https://files.pythonhosted.org/packages/73/03/d6c625d118c2774d73bb37b798f57cdf474b02d9d7330795e0c075485953/gf-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "9b8afddf93eb1874f64374cd55e62687", "sha256": "4d128a7f50780857c12be0fd319d203faf7c16227b1f6073d61ff20084b358c6" }, "downloads": -1, "filename": "gf-0.1.4-py2.7.egg", "has_sig": false, "md5_digest": "9b8afddf93eb1874f64374cd55e62687", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 33800, "upload_time": "2013-12-18T13:00:28", "url": "https://files.pythonhosted.org/packages/21/e7/6374528f302c4c7fc69b108968528de480076368009b0f7d68a98b3add42/gf-0.1.4-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "c5c7ac185cd2117ff5d0bf866020d3de", "sha256": "18a0e767952e31c7e86642a3cd76b40e833dbacf5b538c636fbae82ad9e9d31a" }, "downloads": -1, "filename": "gf-0.1.4.tar.gz", "has_sig": false, "md5_digest": "c5c7ac185cd2117ff5d0bf866020d3de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22495, "upload_time": "2013-12-18T13:00:22", "url": "https://files.pythonhosted.org/packages/4f/b5/ae8e2beceecffd7b77385041f65217c5932333726ef42c7f52ceaec5c665/gf-0.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b8afddf93eb1874f64374cd55e62687", "sha256": "4d128a7f50780857c12be0fd319d203faf7c16227b1f6073d61ff20084b358c6" }, "downloads": -1, "filename": "gf-0.1.4-py2.7.egg", "has_sig": false, "md5_digest": "9b8afddf93eb1874f64374cd55e62687", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 33800, "upload_time": "2013-12-18T13:00:28", "url": "https://files.pythonhosted.org/packages/21/e7/6374528f302c4c7fc69b108968528de480076368009b0f7d68a98b3add42/gf-0.1.4-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "c5c7ac185cd2117ff5d0bf866020d3de", "sha256": "18a0e767952e31c7e86642a3cd76b40e833dbacf5b538c636fbae82ad9e9d31a" }, "downloads": -1, "filename": "gf-0.1.4.tar.gz", "has_sig": false, "md5_digest": "c5c7ac185cd2117ff5d0bf866020d3de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22495, "upload_time": "2013-12-18T13:00:22", "url": "https://files.pythonhosted.org/packages/4f/b5/ae8e2beceecffd7b77385041f65217c5932333726ef42c7f52ceaec5c665/gf-0.1.4.tar.gz" } ] }