{ "info": { "author": "Brett Beatty", "author_email": "brettbeatty@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "HandGrenade: the Python dict where close counts\n===============================================\nHandGrenade is a dict with numeric keys that allows lookup through nearby values. I decided not to call it horseshoe.\n\nBasic Use\n~~~~~~~~~\nWhen given a key not defined, HandGrenade returns the value corresponding to the numerically closest defined key.\n\n.. code-block:: python\n\n >>> from hand_grenade import HandGrenade\n >>> grenade = HandGrenade({0: 'zero', 12: 'twelve'})\n >>> grenade\n HandGrenade({0: 'zero', 12: 'twelve'}, lower=-inf, upper=inf)\n >>> grenade[0]\n 'zero'\n >>> grenade[5]\n 'zero'\n >>> grenade[7]\n 'twelve'\n >>> grenade[12]\n 'twelve'\nHandGrenade also supports the usual dict methods, such as adding/removing/updating items.\n\n.. code-block:: python\n\n >>> grenade[7] = 'seven'\n >>> grenade[11] = 'eleven'\n >>> del grenade[12]\n >>> grenade\n HandGrenade({0: 'zero', 7: 'seven', 11: 'eleven'}, lower=-inf, upper=inf)\n >>> grenade[5]\n 'seven'\n >>> grenade[12]\n 'eleven'\nLower and Upper Bounds\n~~~~~~~~~~~~~~~~~~~~~~\nIf such a feature is desired, HandGrenade allows one to limit the range allowed for its keys. On an attempt to access a key out of the acceptable range, or upon an access to an empty HandGrenade, a KeyError is thrown. This includes the keys in the dict used to construct HandGrenade.\n\n.. code-block:: python\n\n >>> HandGrenade({0: 24}, lower=12)\n Traceback (most recent call last):\n ...\n KeyError: '0'\n >>> HandGrenade()[3]\n Traceback (most recent call last):\n ...\n KeyError: '3'\n >>> grenade = HandGrenade({7: 11}, lower=6, upper=8)\n >>> grenade[5]\n Traceback (most recent call last):\n ...\n KeyError: '5'\n >>> grenade[8] = 3\n >>> grenade[9] = 4\n Traceback (most recent call last):\n ...\n KeyError: '9'\n\n.. note::\n\n Currently, HandGrenade does not support changing bounds after creation. If anyone wants this, `create an issue `_.\nMidpoints\n~~~~~~~~~\nThe midpoints between two adjacent keys should be considered uncertain. Currently, which key is chosen depends on the key's position in HandGrenade's underlying search tree. Therefore, one should expect one of the two nearby keys to be chosen without guarantees as to which.\n\n.. code-block:: python\n\n >>> grenade = HandGrenade({-2: 4, 2: 6})\n >>> assert grenade[0] in {4, 6}\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/brettbeatty/hand_grenade", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "hand_grenade", "package_url": "https://pypi.org/project/hand_grenade/", "platform": "", "project_url": "https://pypi.org/project/hand_grenade/", "project_urls": { "Homepage": "https://github.com/brettbeatty/hand_grenade" }, "release_url": "https://pypi.org/project/hand_grenade/0.1.5/", "requires_dist": null, "requires_python": "", "summary": "the Python dict where close counts", "version": "0.1.5" }, "last_serial": 3422781, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d44cc2a469d626ea139426afcae798bf", "sha256": "4e7078b6e6480000b7aab03ee29c3a2efb92a2305c55a796883d74b370d135a8" }, "downloads": -1, "filename": "hand_grenade-0.1.tar.gz", "has_sig": false, "md5_digest": "d44cc2a469d626ea139426afcae798bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2654, "upload_time": "2017-12-14T20:00:04", "url": "https://files.pythonhosted.org/packages/c9/d8/70329b4b6df1feda0ecd0a6df601bb7b960e4f35dab712dba665c159e87f/hand_grenade-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5bfc47363dfca0a59df1cc20e74dff29", "sha256": "f294fcd3d7fc90a2ac9f1e48b5cfd534fb8b4c1588ab5e126b03174faaaa4881" }, "downloads": -1, "filename": "hand_grenade-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5bfc47363dfca0a59df1cc20e74dff29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2657, "upload_time": "2017-12-14T20:10:54", "url": "https://files.pythonhosted.org/packages/a7/bd/661ecaff14018973c521b7a93ce786e14aee2354cbbbe2fc113362a78094/hand_grenade-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2fb1462e095e54d033a243c17c58dfd6", "sha256": "bd8000a1e947f6fc8856e735d492e464273a759201d8e838165062a1c72e4d68" }, "downloads": -1, "filename": "hand_grenade-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2fb1462e095e54d033a243c17c58dfd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4506, "upload_time": "2017-12-17T07:22:47", "url": "https://files.pythonhosted.org/packages/60/f1/aacdfe51289874187e1585ddbdf41cc6e8d4e2cc03ed3d2bb6afe0eae0e0/hand_grenade-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "243b0a36f4342c71b988c170aa32954e", "sha256": "896cdc51e1135a14b8aa1059676761049ac395ee1f64a2bbd38a5ad1512c782f" }, "downloads": -1, "filename": "hand_grenade-0.1.3.tar.gz", "has_sig": false, "md5_digest": "243b0a36f4342c71b988c170aa32954e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4493, "upload_time": "2017-12-17T08:31:15", "url": "https://files.pythonhosted.org/packages/b3/75/712aa6ef70dc522796e9f29378277348f70fca525a9b63b724e19039e5de/hand_grenade-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "59f209991ca4f1cc58d925f1e53773db", "sha256": "afc53944853f07465b18fe01c92ed422da054da7a56135d58665f2a8ff816cb0" }, "downloads": -1, "filename": "hand_grenade-0.1.4.tar.gz", "has_sig": false, "md5_digest": "59f209991ca4f1cc58d925f1e53773db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4494, "upload_time": "2017-12-17T08:57:00", "url": "https://files.pythonhosted.org/packages/e4/8f/87b89313ddcc817e964cc7b4d63b44875e26c9188ddae02886aa5747b0a6/hand_grenade-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "f84d35ec226740373372fc3484352bbe", "sha256": "afa891a7ab72ab4137ffdb366ed3987939084234bc82afdd9d0c2d8acb38d46a" }, "downloads": -1, "filename": "hand_grenade-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f84d35ec226740373372fc3484352bbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4490, "upload_time": "2017-12-17T09:17:21", "url": "https://files.pythonhosted.org/packages/af/35/85e7186ec1b025c51548abb4bb3c1b6e82bea21bd05e811f06b5a43239ee/hand_grenade-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f84d35ec226740373372fc3484352bbe", "sha256": "afa891a7ab72ab4137ffdb366ed3987939084234bc82afdd9d0c2d8acb38d46a" }, "downloads": -1, "filename": "hand_grenade-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f84d35ec226740373372fc3484352bbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4490, "upload_time": "2017-12-17T09:17:21", "url": "https://files.pythonhosted.org/packages/af/35/85e7186ec1b025c51548abb4bb3c1b6e82bea21bd05e811f06b5a43239ee/hand_grenade-0.1.5.tar.gz" } ] }