Skip to main content

A tool used to easily reorder dictionary indexes.

Project description

dict-reorder

dict-reorder is a Python package designed to reorder dictionaries.

Usage

Swapping keys:

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:

dict_reorder.changeKeyIndex(example, "compound_name", 0)

Creating your own dictionary and assigning to indexes can also be done:

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
#}

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dict_reorder-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

dict_reorder-0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file dict_reorder-0.1.tar.gz.

File metadata

  • Download URL: dict_reorder-0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for dict_reorder-0.1.tar.gz
Algorithm Hash digest
SHA256 42ed139884175cdba794f3d82d5d5d82f64e43b7070393b1aca67ea17fb9b66b
MD5 9d5bea5939b823fc3fa82dba8df9795d
BLAKE2b-256 d638ee02dce25e20b347dcecbb77ca576f01eb182ecbfe466009e5af7903e607

See more details on using hashes here.

File details

Details for the file dict_reorder-0.1-py3-none-any.whl.

File metadata

  • Download URL: dict_reorder-0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for dict_reorder-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e6873283b909befc2030236fa9543521f937ac3cc6cc811ec35d724c25635c
MD5 46c5e55b7aa8fc62f457fe2d2f917cd1
BLAKE2b-256 9b1a1a3d376a83468af92165b3ef238d1efd3d79d1a67fa3aead21056986eadc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page