{ "info": { "author": "Matthias Bussonnier", "author_email": "bussonniermatthias@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License" ], "description": "positionnal only arguments/parameters\n=====================================\n\nModule to fake positional only arguments (pep 497, Draft).\n\nLet's take the following function as example:\n\n.. code:: python\n\n def diff(left, right, context=3):\n '''print the diff between `left` and `right` with `context`\n '''\n ...\n\n``right`` and ``left`` are now part of the API, and users may decide to\nuse ``diff(left=str1, right=str1)``, blocking api changes, so you can't\nchange the names of the parameters, to for example\n``def diff(old, new, context=3)`` without using the C-api.\n\nThis module provide a decorator @positionalonly to make all the\ndefault-less parameters of your function positional only, so you can\nwrite:\n\n::\n\n @positionalonly\n def diff(left, right, context=3):\n ...\n\nUsingit like will raise a TypeError, and the function signature will use\nthe positional only argument syntax with the ``/`` of pep 497.\n\n::\n\n >>> diff(right=\"bar\", left=\"foo\")\n TypeError: The following parameters of `diff` are positional only.\n They were used as keywords arguments:\n - 'right' ('bar') should be in 2nd position\n - 'left' ('foo') should be in 1st position\n\n >>> help(diff)\n Help on function diff in module __main__:\n\n diff(left, right, /, context=3)\n\nAdvanced usage\n==============\n\nBy default ``positionalonly`` will make the limit between\npositional-only and the rest of the arguments just before the first\nargument with default. You can tweek this behavior by passing an integer\nas parameter indicating the number of argument to make positional-only:\n\n::\n\n >>> @positionalonly(3)\n ... def diff(old, new, context=3)\n ... pass\n\n >>> signature(diff)\n diff(left, right, context=3, /)\n\n\n >>> @positionalonly(1)\n ... def diff(old, new, context=3)\n ... pass\n\n >>> signature(diff)\n diff(left, /, right, context=3)\n\nIf you are too lazy to count, or are afraid of misscounting,\n``positionalonly`` will also decide to put the limit to the first\nargument which default value is ``positionalonly`` itself.\n\n::\n\n >>> @positionalonly\n ... def diff(old, new, end=positionalonly, context=3)\n ... pass\n\n >>> signature(diff)\n diff(left, right, /, context=3)\n\n >>> pos_or_kw\n >>> @positionalonly\n ... def diff(old, start=pos_or_kw, context=3)\n ... pass\n\n >>> signature(diff)\n diff(left, /, right, context=3)\n\nReasons to use positional only\n==============================\n\nNaming of argument, and in particular the function signature can be\nhelfull for tab completion, and static analysis to understand the code.\nWhile posistional only is usable using ``*args`` it hides all this\ninformation both from the human and the computer.\n\nThe default behavior of Python, is to make agument by dafult, positional\nan keyword.\n\nThis fact often prevent the developer from changing the name without\nbreaking the API.\n\nThis also prevent arbitrary ``**kwargs`` keys as they are be taken by\n\"positionaly or keyword\" arguments.\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/Carreau/positionalonly", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "positionalonly", "package_url": "https://pypi.org/project/positionalonly/", "platform": "", "project_url": "https://pypi.org/project/positionalonly/", "project_urls": { "Homepage": "https://github.com/Carreau/positionalonly" }, "release_url": "https://pypi.org/project/positionalonly/0.0.3/", "requires_dist": null, "requires_python": ">=3.5", "summary": "positionnal only arguments/parameters", "version": "0.0.3" }, "last_serial": 2674247, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "58f0de155a2eca5ae8804ad31f938eb1", "sha256": "f999e0b2677af6cb1e02844b2c8759329d0c2d38d8487e14250945356b6e5d72" }, "downloads": -1, "filename": "positionalonly-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "58f0de155a2eca5ae8804ad31f938eb1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 74280, "upload_time": "2017-01-02T18:41:05", "url": "https://files.pythonhosted.org/packages/19/5f/1a0c721479bd45f85e69cf2aa44f6ea13cf75eb6d829105fddc8edaddf01/positionalonly-0.0.1-py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "dbd0e72168c5551d1384627e7a1d3ada", "sha256": "fa9145b0e2da97db635b1df32ea843c6610bca34a4f6ac630306e448b21250c2" }, "downloads": -1, "filename": "positionalonly-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "dbd0e72168c5551d1384627e7a1d3ada", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 52976, "upload_time": "2017-02-28T22:38:44", "url": "https://files.pythonhosted.org/packages/05/ed/e558142dc3d8e3ee508cd5f42e5985cb41034719cd2997316afdc7767941/positionalonly-0.0.2-py3-none-any.whl" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "17a0888bd6492f50b72272281f5e4dfd", "sha256": "5f5113426703c24a45b557d2cbe3252c96a48f82df7698533fc8aa19660d5ec2" }, "downloads": -1, "filename": "positionalonly-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "17a0888bd6492f50b72272281f5e4dfd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 71072, "upload_time": "2017-02-28T22:41:58", "url": "https://files.pythonhosted.org/packages/ad/e7/ce957478200a82a3b6ba818a10ce32c9979fe425579a5253902d4f9d5420/positionalonly-0.0.3-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "17a0888bd6492f50b72272281f5e4dfd", "sha256": "5f5113426703c24a45b557d2cbe3252c96a48f82df7698533fc8aa19660d5ec2" }, "downloads": -1, "filename": "positionalonly-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "17a0888bd6492f50b72272281f5e4dfd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 71072, "upload_time": "2017-02-28T22:41:58", "url": "https://files.pythonhosted.org/packages/ad/e7/ce957478200a82a3b6ba818a10ce32c9979fe425579a5253902d4f9d5420/positionalonly-0.0.3-py3-none-any.whl" } ] }