{ "info": { "author": "Richard Jones", "author_email": "richard@python.org", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "Simple overloading of methods and functions through an @overload decorator.\n\nThis module allows one to provide multiple interfaces for a functions,\nmethods, classmethods, staticmethods or classes. See below for some notes\nabout overloading classes, you strange person you.\n\nThe appropriate implementation is chosen based on the calling argument\npattern.\n\nFor example:\n\n>>> class A(object):\n... @overload\n... def method(self, a):\n... return 'a'\n... @method.add\n... def method(self, a, b):\n... return 'a, b'\n... \n>>> a = A()\n>>> a.method(1)\n'a'\n>>> a.method(1, 2)\n'a, b'\n\nThe overloading handles fixed, keyword, variable (``*args``) and arbitrary\nkeyword (``**keywords``) arguments.\n\nIt also handles annotations if those annotations are types:\n\n>>> @overload\n... def func(a:int):\n... return 'int'\n... \n>>> @func.add\n... def func(a:str):\n... return 'str'\n... \n>>> func(1)\n'int'\n>>> func('s')\n'str'\n>>> func(1.0)\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"overload.py\", line 94, in f\n raise TypeError('invalid call argument(s)')\nTypeError: invalid call argument(s)\n\nThis feature (and currently the module in general) requires Python 3.\n\nThe docstring and name (ie. documentation) of the resultant callable will\nmatch that of the *first* callable overloaded.\n\n\nOverloading Classes\n--------------------\n\nOverloading classes allows you to select a class type based on the\nconstruction arguments of each alternative type's __new__ method.\n\nThere's a catch though: the __new__ method must *explicitly* invoke the\nbase class __new__ method, rather than use super() like usual. This is\nbecause after being @overloaded the class is a function, and super()\ndoesn't like being passed functions. So instead of::\n\n @overload\n class A(object):\n def __new__(cls):\n # this will fail because \"A\" is a function now\n return super(A, cls).__new__(cls)\n\nyou must::\n\n @overload\n class A(object):\n def __new__(cls):\n # must explicitly reference the base class\n return object.__new__(cls)\n\nI'll leave it up to the reader to justify their use of @overloading\nclasses.\n\n\nVersion History (in Brief)\n--------------------------\n\n- 1.1 altered the text of the invalid call TypeError. Removed debug prints.\n- 1.0 the initial release\n\nSee the end of the source file for the license of use.\n\n----\n\nI would be interested to know whether this module is useful - if you use it\nplease indicate so at https://www.ohloh.net/p/pyoverload", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/overload", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "overload", "package_url": "https://pypi.org/project/overload/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/overload/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/overload" }, "release_url": "https://pypi.org/project/overload/1.1/", "requires_dist": null, "requires_python": null, "summary": "Simple overloading of methods and functions through an @overload decorator", "version": "1.1" }, "last_serial": 795891, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "e18f475dbaf893fb1f94dbfa26c76519", "sha256": "ca07c7dfa79ac7ca85498e06b31dd340ba76e72297f287cfddb1001ab8d583fe" }, "downloads": -1, "filename": "overload-1.0.tar.gz", "has_sig": false, "md5_digest": "e18f475dbaf893fb1f94dbfa26c76519", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4581, "upload_time": "2011-05-05T10:36:06", "url": "https://files.pythonhosted.org/packages/0d/f0/3c9de1afe6f44c4ebbae8741536417d142cf657ebce24e7ff9f975f09353/overload-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "35f44b5fc7380faca79b06d063d0e6c7", "sha256": "215740c5c374b6039e1fb196e127316d3203b76795e2aa137a7f9376621b5592" }, "downloads": -1, "filename": "overload-1.1.tar.gz", "has_sig": false, "md5_digest": "35f44b5fc7380faca79b06d063d0e6c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4605, "upload_time": "2011-05-05T10:51:05", "url": "https://files.pythonhosted.org/packages/39/49/241d870d1f93fcd9c6d426254128ed0bc3ca524cf963d8f5414540482853/overload-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "35f44b5fc7380faca79b06d063d0e6c7", "sha256": "215740c5c374b6039e1fb196e127316d3203b76795e2aa137a7f9376621b5592" }, "downloads": -1, "filename": "overload-1.1.tar.gz", "has_sig": false, "md5_digest": "35f44b5fc7380faca79b06d063d0e6c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4605, "upload_time": "2011-05-05T10:51:05", "url": "https://files.pythonhosted.org/packages/39/49/241d870d1f93fcd9c6d426254128ed0bc3ca524cf963d8f5414540482853/overload-1.1.tar.gz" } ] }