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.5.1.tar.gz (5.1 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.5.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dottable_dict-0.0.5.1.tar.gz
  • Upload date:
  • Size: 5.1 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.5.1.tar.gz
Algorithm Hash digest
SHA256 39e47c9909c607f2ada9586855bbf6df9c5f5e931c988d795bfc4d1117d1d017
MD5 6a7d0dfce29c94642e9dc6491c9b7d0d
BLAKE2b-256 630102800c1404ba2859cc567de8e088af5e238acf6ceb387dd54f531363be14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dottable_dict-0.0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c40f06dbe0c711797ed77327be78da484586bb9a713b190a66c183ee6150ab53
MD5 6902e524d1d86c016278f7dfb1694c4c
BLAKE2b-256 8dda54afa5a517a26022ea731e9e80992f5ef469e2158523e938b016f1216973

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