Skip to main content

Your everyday dictionary, with the special ability to be accessed using dot-notation

Project description

Dottable Dictionary

Your everyday dictionary, with the special ability to be accessed using dot-notation.

Use dottable dictionaries to turn this:
d["somekey"]["some_inner_key"]["some_internal_key"]
to this:
d.somekey.some_inner_key.some_internal_key.

Background

The basic idea behind this package was to migrate JavaScript's dot-notation access to Python dictionaries. In many (maybe most) cases, dictionaries are used with keys which can serve as identifiers (for more on those take a look here).
By taking advantage of this, dictionary access can be as intuitive as accessing properties within an object (rather than being constrained to using strings).

Importantly - dottable dictionaries are first and foremost dictionaries. Therefore, they implement the same basic functionalities as native dict objects, and are generally designed to interact with them as seamlessly as possible, such that using dottable dictionaries should be compatible with existing code and/or any external module/package.

Functionality

Dictionary functionality

Some basic native dict functionalities which are implemented in dottable dictionaries:

  • copy()
  • update()
  • keys(), values(), items()
  • in operator (__contains__())
  • Iterability (__iter__)
  • TBD: setdefault

Extra functionality

Some extra functionality (extending native dict functionality):

  • Adding & merging: merging mappings to get a unified view of all values (also availble using the + operator)
  • Access by complex string paths - set/get properties using a dot-separated path (e.g., ["a"]["b"]["c"] <-> "a.b.c"). This can be useful for dynamically accessing properties in objects with complex data schemas.
  • Immutable copies - generating an immutable copy of the current state of the mapping. This is also used to allow a pseudo-hash of the mapping (i.e., hash of the current state)

Conversions

Dottable dictionaries can be directly (recursively) converted to native dict objects by using the simple_dict property.

Project details


Download files

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

Source Distribution

dottable_dict-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dottable_dict-0.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file dottable_dict-0.0.3.tar.gz.

File metadata

  • Download URL: dottable_dict-0.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for dottable_dict-0.0.3.tar.gz
Algorithm Hash digest
SHA256 57f0c20aa90a174f49952735cb94fa537ed4422e934f5766e22a4fc1dc45cabf
MD5 caaa643c416ff19a4b277b1cc92b2999
BLAKE2b-256 62f365249745d8bc2f1fe06bd64ec3441589ba4c8b67d054f801558b8e9b893f

See more details on using hashes here.

File details

Details for the file dottable_dict-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: dottable_dict-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for dottable_dict-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a0b729fc895c68b7c743ad356cdd572b3cbb18d9631b0c4800e72d80edb4665e
MD5 2075c492f3d6eaaf3e4ab2a2176ee640
BLAKE2b-256 ac0a60947839ddae76269a5cff809bd613d65b4023da8b9dcd244fafaf1abd4e

See more details on using hashes here.

Supported by

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