{ "info": { "author": "DiscreteTom", "author_email": "discrete_tom@outlook.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# refdict\n\n![PyPI](https://img.shields.io/pypi/v/refdict.svg)\n![GitHub](https://img.shields.io/github/license/DiscreteTom/refdict.svg)\n\n## Usage\n\n- Using string as chain keys to realize chain access(including `dict`/`list`/`tuple`/`str`).\n- String can perform as a reference of another item.\n\n![](https://raw.githubusercontent.com/DiscreteTom/refdict/master/img/readme.png)\n\n## Install\n\n`pip install refdict`\n\n## Features\n\n- Using `refdict` just like using `dict`/`list`/`tuple`/`str`.\n - Methods of built-in types: `refdict({}).keys()` or `refdict([]).append(123)`.\n - Iteration and containment check: `for x in refdict([1, 2, 3])`.\n - Slice and slice assignment: `refdict([1, 2, 3])[:] => [1, 2, 3]`.\n - ...\n- Chain accessing members using a string.\n - `refdict({'1':{'1':{'1':{'1':'1'}}}})['1.1.1.1'] => 1`.\n- Using reference string to reference another item.\n\n## Description\n\nUse **reference prefix** to turn a string into a reference of another item. The default reference prefix is `@`. Reference prefix can be changed by the parameter `refPrefix` of the constructor of refdict.\n\nThe `[]` operator can be used for chain access and reference access. The separator of keys is `.` by default, and it can be changed by the parameter `separator` of the constructor.\n\nHere is an example:\n\n```python\ndata = {\n\t'player': {\n\t\t'name': 'DiscreteTom',\n\t\t'items': [\n\t\t\t'@potion.red'\n\t\t],\n\t\t'weapon': '@sword',\n\t\t'attack': '@player.weapon.attack',\n\t\t'me': '@player'\n\t},\n\t'potion': {\n\t\t'red': 'restore your health by 20%',\n\t},\n\t'sword': {\n\t\t'attack': 123\n\t},\n}\nrd = refdict(data)\nprint(rd['player.items.0']) # => restore your health by 20%\nprint(rd['player.attack']) # => 123\nprint(rd['player.items.:']) # => ['@potion.red']\nprint(rd.text('player.attack')) # => @player.weapon.attack\nprint('player.weapon' in rd) # => True\n```\n\n## Warnings\n\n**Recursive references** like `item: @item` will cause **infinite loop**, including indirect reference.\n\n```python\ndata = {\n\t'item': '@item', # => infinite loop!\n\t'wrapper': {\n\t\t'item': '@wrapper.item' # => infinite loop!\n\t},\n\t'a': '@b' # => infinite loop!\n\t'b': '@a' # => infinite loop!\n}\n```\n\n## FAQ\n\n- Q - Why I can't access the first item of `list`/`tuple`/`str` using `[1]`?\n - A - Of course you should use `[0]` to access the first item, just like using `list`/`tuple`/`str`. It's a little bit counter-intuitive but reasonable.\n- Q - Why I got `KeyError` when using `rd['key1.key2']['key3.key4']`?\n - The first `[]` operator will return a non-refdict object, so you can't use chain keys in the following `[]`. To get a sub-refdict, you should use `()` operator, which means you should use `rd('key1.key2')['key3.key4']`.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/DiscreteTom/refdict", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "refdict", "package_url": "https://pypi.org/project/refdict/", "platform": "", "project_url": "https://pypi.org/project/refdict/", "project_urls": { "Homepage": "https://github.com/DiscreteTom/refdict" }, "release_url": "https://pypi.org/project/refdict/3.3.0/", "requires_dist": null, "requires_python": "", "summary": "Using string as chain keys to realize chain access and reference access of dict in python", "version": "3.3.0" }, "last_serial": 5591632, "releases": { "2.0.1": [ { "comment_text": "", "digests": { "md5": "c61815f80de1362102da836e18b29107", "sha256": "eabbb11e28dcc07565b9367fdc9d894d30eb6aa9a91707a772cb7965a0f8ecd9" }, "downloads": -1, "filename": "refdict-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c61815f80de1362102da836e18b29107", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15941, "upload_time": "2019-05-22T15:39:14", "url": "https://files.pythonhosted.org/packages/93/03/192b95404dbc863ca6ed202690ffebf52941c08091490d5591078ed5c059/refdict-2.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0b774cfcc4f18d6c3a4775da573b7c75", "sha256": "22c65a2103962cf47a0030686c3c109738a9d6c4950d2ae5b927b3dd20edca56" }, "downloads": -1, "filename": "refdict-2.0.1.tar.gz", "has_sig": false, "md5_digest": "0b774cfcc4f18d6c3a4775da573b7c75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3547, "upload_time": "2019-05-22T15:39:16", "url": "https://files.pythonhosted.org/packages/db/32/3b16e8c3c3866d02840d87ed2950bfdf5a89edd4ece40174c4c707681fe2/refdict-2.0.1.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "d082849ae07e81c1e871d9c1ac1d4bce", "sha256": "d0c9839c946d34643a503e2a462004e2c4770d3e5ce40172c34a7da756ff8db6" }, "downloads": -1, "filename": "refdict-2.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d082849ae07e81c1e871d9c1ac1d4bce", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16506, "upload_time": "2019-05-25T15:08:08", "url": "https://files.pythonhosted.org/packages/27/6d/6a6df654bcb3f67d265d60f891bfa3e38649e824ecab5e03cf031f3ca502/refdict-2.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8257b72f31c1c158cd5c194a5b100209", "sha256": "febac44c612a677f25088b29b305869f0a0ed066ae95b56a8bd5cf9192badfdf" }, "downloads": -1, "filename": "refdict-2.1.0.tar.gz", "has_sig": false, "md5_digest": "8257b72f31c1c158cd5c194a5b100209", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4162, "upload_time": "2019-05-25T15:08:11", "url": "https://files.pythonhosted.org/packages/2c/78/87fe0a67e24da7a5d770b8556246b21dc03bce8d40118180221d0d5581f7/refdict-2.1.0.tar.gz" } ], "2.2.0": [ { "comment_text": "", "digests": { "md5": "a5c68c88dec60766847118821da95ee7", "sha256": "074a4db0e856d88dac8e98ea7847fc996561d551f00b2d83fb6ab03effbf05c8" }, "downloads": -1, "filename": "refdict-2.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a5c68c88dec60766847118821da95ee7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16617, "upload_time": "2019-05-28T06:46:02", "url": "https://files.pythonhosted.org/packages/2b/d6/cec12eb6bd2afd21d0ae74e44a0697b248581a205fe15143041f5c1bdc04/refdict-2.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff9d51c6eb18624bc312602c2e7dfce1", "sha256": "32d14af612bd56558fa4168f567bc01195b9a3fe3ba90c23a6ebea191a6ab16e" }, "downloads": -1, "filename": "refdict-2.2.0.tar.gz", "has_sig": false, "md5_digest": "ff9d51c6eb18624bc312602c2e7dfce1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4297, "upload_time": "2019-05-28T06:46:07", "url": "https://files.pythonhosted.org/packages/2b/d0/adf524df0a4488e972d9b875d16bd53f9edacb29ea812f45823ce080fda9/refdict-2.2.0.tar.gz" } ], "2.2.1": [ { "comment_text": "", "digests": { "md5": "27fd6b15650527c27b1f0306a64f2d04", "sha256": "36099004c9fc4624fc961794cf6c5eb556573a48341c0597ef2fd24424404cd6" }, "downloads": -1, "filename": "refdict-2.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "27fd6b15650527c27b1f0306a64f2d04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16622, "upload_time": "2019-05-28T09:01:09", "url": "https://files.pythonhosted.org/packages/d5/55/478a3e7715bddd23f52572a3d2f680f8bf45d179f30a2835ef40c47b778a/refdict-2.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3545ae54e3497a7b966c212d2a5a07b", "sha256": "508e466631e5b5fa64c5acc8fc46f31c20d5984adc683f9803ca79467aaacb3a" }, "downloads": -1, "filename": "refdict-2.2.1.tar.gz", "has_sig": false, "md5_digest": "f3545ae54e3497a7b966c212d2a5a07b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4293, "upload_time": "2019-05-28T09:01:11", "url": "https://files.pythonhosted.org/packages/bc/94/f7e611a0cf825758ab8454279ed9d1fff4fc038805b3da019fe93a019535/refdict-2.2.1.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "62453022df0d69569a2c5d511d21d7db", "sha256": "d02e4c7baf883a389a77fad73023171f77c3efbf81ec805efae0e3ae45bd7c57" }, "downloads": -1, "filename": "refdict-3.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "62453022df0d69569a2c5d511d21d7db", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17334, "upload_time": "2019-05-31T02:48:50", "url": "https://files.pythonhosted.org/packages/84/a2/9170ef90e63c88969ca9429c2175b4ef67aebaddd089963c91b058c4aa92/refdict-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e869da8007a64f8aac5a6cf611746260", "sha256": "4999aa65b366063afa680a8b717fd6721c91e0192b0e5487001733f7fac673f2" }, "downloads": -1, "filename": "refdict-3.0.0.tar.gz", "has_sig": false, "md5_digest": "e869da8007a64f8aac5a6cf611746260", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5096, "upload_time": "2019-05-31T02:48:54", "url": "https://files.pythonhosted.org/packages/34/11/03386322db040e99302a874f8fd9d1a785eb4a0e231951c5c08afc8ee458/refdict-3.0.0.tar.gz" } ], "3.1.0": [ { "comment_text": "", "digests": { "md5": "642eed96fc545ace5660bb3906b5f02b", "sha256": "6ab166309f025914e18426f5619c8b2eafa17bfe50912ae0c8f89926634d7a09" }, "downloads": -1, "filename": "refdict-3.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "642eed96fc545ace5660bb3906b5f02b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17472, "upload_time": "2019-06-20T14:12:34", "url": "https://files.pythonhosted.org/packages/6d/92/384e96159c309ffbe9a6bedaea58c37f64b3bcc5f66d799a4dd049d35682/refdict-3.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6649d3115a54644b6e7fada28fe4f8a4", "sha256": "6a731d25f4a27ce93e7c395c1b5234599ffa415521dee4b1459f932056e61969" }, "downloads": -1, "filename": "refdict-3.1.0.tar.gz", "has_sig": false, "md5_digest": "6649d3115a54644b6e7fada28fe4f8a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5252, "upload_time": "2019-06-20T14:12:39", "url": "https://files.pythonhosted.org/packages/ba/f7/8fff993e0f02bf4e5c588aa89174a432ef4e6802f431d5b8579f747a32c3/refdict-3.1.0.tar.gz" } ], "3.2.0": [ { "comment_text": "", "digests": { "md5": "fbf834cfa757b94014a1a6019aadc3a4", "sha256": "7dd78258500f3a8043a674d17500661ad35d7ec9e1a6a7153a3a15e05ea554d6" }, "downloads": -1, "filename": "refdict-3.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fbf834cfa757b94014a1a6019aadc3a4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17620, "upload_time": "2019-07-02T01:44:52", "url": "https://files.pythonhosted.org/packages/ed/32/ed16b99f3704f1fd913185f43ab855c7005e2ae4c571a05a21b5e26c40cc/refdict-3.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "75a55ec689fd80cd41ebdce714ed0ac9", "sha256": "470896e112e3e6cfa23e081596748d359a596727dcc33861c09d8ab6e0433cfd" }, "downloads": -1, "filename": "refdict-3.2.0.tar.gz", "has_sig": false, "md5_digest": "75a55ec689fd80cd41ebdce714ed0ac9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5421, "upload_time": "2019-07-02T01:44:56", "url": "https://files.pythonhosted.org/packages/18/0f/340bffbf3b5fed9bd4e6a2f7bd2530f20433111d61c85fe7f7d73113139c/refdict-3.2.0.tar.gz" } ], "3.2.1": [ { "comment_text": "", "digests": { "md5": "ec5bfbaf04db6289fe2ce5c30f00ec85", "sha256": "22303f15ab87dc90d0ca07e03b9844227d34f584883d12b58b1eb7b23734c3fd" }, "downloads": -1, "filename": "refdict-3.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ec5bfbaf04db6289fe2ce5c30f00ec85", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16463, "upload_time": "2019-07-21T09:04:23", "url": "https://files.pythonhosted.org/packages/26/fe/4c6f4fb83b8fd9420b43cfa0142fe5b1bf4f61855ebc43e57a301714e1ba/refdict-3.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0c457de49d84c76bb47d1778afb0631c", "sha256": "658b4a985c94eea0afdfc39bdc831a0f920d4932bffdeb61326979d00e156af8" }, "downloads": -1, "filename": "refdict-3.2.1.tar.gz", "has_sig": false, "md5_digest": "0c457de49d84c76bb47d1778afb0631c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3892, "upload_time": "2019-07-21T09:04:29", "url": "https://files.pythonhosted.org/packages/ea/b3/1691389ecb5aca2dfd5960bd2f1cd1a1cc6e5826739d5c2f55c2ee42a274/refdict-3.2.1.tar.gz" } ], "3.3.0": [ { "comment_text": "", "digests": { "md5": "76ddaa4cc3e5d1ac2137af88cd50729c", "sha256": "e894c0047411915da74488b922eb16981a30d0ee83f625e5b535c86fc4e9c075" }, "downloads": -1, "filename": "refdict-3.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "76ddaa4cc3e5d1ac2137af88cd50729c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16465, "upload_time": "2019-07-27T03:18:25", "url": "https://files.pythonhosted.org/packages/5e/1f/4de580c2bb4b3f5f30950c935e838bf6b10a99fecf15c4e670673ced974d/refdict-3.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "77a9ed8b282c935b8a1970d9db38d776", "sha256": "810fd8cc805633f7bf46b6be0b04f8405a3de159f9de0129a76959ed357b5c76" }, "downloads": -1, "filename": "refdict-3.3.0.tar.gz", "has_sig": false, "md5_digest": "77a9ed8b282c935b8a1970d9db38d776", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3898, "upload_time": "2019-07-27T03:18:33", "url": "https://files.pythonhosted.org/packages/ba/ef/01854fed92610a9d88b491d04df4de6d82410b5850036aa0e9ef514a9071/refdict-3.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "76ddaa4cc3e5d1ac2137af88cd50729c", "sha256": "e894c0047411915da74488b922eb16981a30d0ee83f625e5b535c86fc4e9c075" }, "downloads": -1, "filename": "refdict-3.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "76ddaa4cc3e5d1ac2137af88cd50729c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16465, "upload_time": "2019-07-27T03:18:25", "url": "https://files.pythonhosted.org/packages/5e/1f/4de580c2bb4b3f5f30950c935e838bf6b10a99fecf15c4e670673ced974d/refdict-3.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "77a9ed8b282c935b8a1970d9db38d776", "sha256": "810fd8cc805633f7bf46b6be0b04f8405a3de159f9de0129a76959ed357b5c76" }, "downloads": -1, "filename": "refdict-3.3.0.tar.gz", "has_sig": false, "md5_digest": "77a9ed8b282c935b8a1970d9db38d776", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3898, "upload_time": "2019-07-27T03:18:33", "url": "https://files.pythonhosted.org/packages/ba/ef/01854fed92610a9d88b491d04df4de6d82410b5850036aa0e9ef514a9071/refdict-3.3.0.tar.gz" } ] }