dict-reorder


Namedict-reorder JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/xyzpw/dict-reorder/
SummaryA tool used to easily reorder dictionary indexes.
upload_time2024-08-11 04:25:47
maintainerxyzpw
docs_urlNone
authorxyzpw
requires_pythonNone
licenseMIT
keywords dictionaries manipulator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dict-reorder
**dict-reorder** is a Python package designed to reorder dictionaries.

## Usage
Swapping keys:
```python
import dict_reorder
example = {
    "chemical_formula": "NaCl",
    "compound_name": "Sodium Chloride",
    "molar_mass": 58.443,
    "state_at_room_temp": "solid",
    "melting_point": 800.7,
    "boiling_point": 1465,
    "solubility_in_water": "high",
    "hazard_classification": None
}
example = dict_reorder.swapKeys(example, "compound_name", "chemical_formula")
# New value:
#{
# 'compound_name': 'Sodium Chloride',
# 'chemical_formula': 'NaCl',
# 'molar_mass': 58.443,
# 'state_at_room_temp': 'solid',
# 'melting_point': 800.7,
# 'boiling_point': 1465,
# 'solubility_in_water': 'high',
# 'hazard_classification': None
#}

```

This can also be done with indexes:
```python
dict_reorder.changeKeyIndex(example, "compound_name", 0)
```

Creating your own dictionary and assigning to indexes can also be done:
```python
from dict_reorder import DictReorder
planet = DictReorder()
planet.addKey(name="name", value="earth", index=0)
planet.addKey("gravity", 9.80665, index=2)
planet.addKey("mass", 5.97219e24, 1)
planetInfo = planet.getDictionary()
# `planetInfo`
#{
# 'name': 'earth',
# 'mass': 5.9722e+24,
# 'gravity': 9.80665
#}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xyzpw/dict-reorder/",
    "name": "dict-reorder",
    "maintainer": "xyzpw",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "dictionaries, manipulator",
    "author": "xyzpw",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d6/38/ee02dce25e20b347dcecbb77ca576f01eb182ecbfe466009e5af7903e607/dict_reorder-0.1.tar.gz",
    "platform": null,
    "description": "# dict-reorder\n**dict-reorder** is a Python package designed to reorder dictionaries.\n\n## Usage\nSwapping keys:\n```python\nimport dict_reorder\nexample = {\n    \"chemical_formula\": \"NaCl\",\n    \"compound_name\": \"Sodium Chloride\",\n    \"molar_mass\": 58.443,\n    \"state_at_room_temp\": \"solid\",\n    \"melting_point\": 800.7,\n    \"boiling_point\": 1465,\n    \"solubility_in_water\": \"high\",\n    \"hazard_classification\": None\n}\nexample = dict_reorder.swapKeys(example, \"compound_name\", \"chemical_formula\")\n# New value:\n#{\n# 'compound_name': 'Sodium Chloride',\n# 'chemical_formula': 'NaCl',\n# 'molar_mass': 58.443,\n# 'state_at_room_temp': 'solid',\n# 'melting_point': 800.7,\n# 'boiling_point': 1465,\n# 'solubility_in_water': 'high',\n# 'hazard_classification': None\n#}\n\n```\n\nThis can also be done with indexes:\n```python\ndict_reorder.changeKeyIndex(example, \"compound_name\", 0)\n```\n\nCreating your own dictionary and assigning to indexes can also be done:\n```python\nfrom dict_reorder import DictReorder\nplanet = DictReorder()\nplanet.addKey(name=\"name\", value=\"earth\", index=0)\nplanet.addKey(\"gravity\", 9.80665, index=2)\nplanet.addKey(\"mass\", 5.97219e24, 1)\nplanetInfo = planet.getDictionary()\n# `planetInfo`\n#{\n# 'name': 'earth',\n# 'mass': 5.9722e+24,\n# 'gravity': 9.80665\n#}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool used to easily reorder dictionary indexes.",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/xyzpw/dict-reorder/"
    },
    "split_keywords": [
        "dictionaries",
        " manipulator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b1a1a3d376a83468af92165b3ef238d1efd3d79d1a67fa3aead21056986eadc",
                "md5": "46c5e55b7aa8fc62f457fe2d2f917cd1",
                "sha256": "d0e6873283b909befc2030236fa9543521f937ac3cc6cc811ec35d724c25635c"
            },
            "downloads": -1,
            "filename": "dict_reorder-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "46c5e55b7aa8fc62f457fe2d2f917cd1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3573,
            "upload_time": "2024-08-11T04:25:46",
            "upload_time_iso_8601": "2024-08-11T04:25:46.471443Z",
            "url": "https://files.pythonhosted.org/packages/9b/1a/1a3d376a83468af92165b3ef238d1efd3d79d1a67fa3aead21056986eadc/dict_reorder-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d638ee02dce25e20b347dcecbb77ca576f01eb182ecbfe466009e5af7903e607",
                "md5": "9d5bea5939b823fc3fa82dba8df9795d",
                "sha256": "42ed139884175cdba794f3d82d5d5d82f64e43b7070393b1aca67ea17fb9b66b"
            },
            "downloads": -1,
            "filename": "dict_reorder-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9d5bea5939b823fc3fa82dba8df9795d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3278,
            "upload_time": "2024-08-11T04:25:47",
            "upload_time_iso_8601": "2024-08-11T04:25:47.942387Z",
            "url": "https://files.pythonhosted.org/packages/d6/38/ee02dce25e20b347dcecbb77ca576f01eb182ecbfe466009e5af7903e607/dict_reorder-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-11 04:25:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xyzpw",
    "github_project": "dict-reorder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dict-reorder"
}
        
Elapsed time: 1.39772s