All Projects → pawelzny → dotty_dict

pawelzny / dotty_dict

Licence: MIT License
Dictionary wrapper for quick access to deeply nested keys.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to dotty dict

packetevents
PacketEvents is a powerful packet library. Our packet wrappers are efficient and easy to use. We support many protocol versions. (1.8+)
Stars: ✭ 235 (+250.75%)
Mutual labels:  wrapper, utils
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+4002.99%)
Mutual labels:  utils, lib
permissionUtil
Simple permission helper
Stars: ✭ 64 (-4.48%)
Mutual labels:  helper, utils
GoGPUtils
Enhance productivity and avoid to reinvent the wheel every time that you start a Go project
Stars: ✭ 29 (-56.72%)
Mutual labels:  helper, utils
Assembly-Lib
A 16-bits x86 DOS Assembly library that provides many useful functions for developing programs. It has both VGA grapics functions as well as general purpose utilities. The main purpose of this library was to be able to implement simple DOS games (in Assembly) using VGA (320x200, 256 colors) display.
Stars: ✭ 36 (-46.27%)
Mutual labels:  utils, lib
BDHelper
An Helper Bot For BDReborn Based On BDMessenger :)
Stars: ✭ 21 (-68.66%)
Mutual labels:  helper
clearbit-go
Go bindings for Clearbit
Stars: ✭ 12 (-82.09%)
Mutual labels:  utils
pwnscripts
Very simple script(s) to hasten binary exploit creation
Stars: ✭ 66 (-1.49%)
Mutual labels:  wrapper
ZetaHtmlEditControl
A small wrapper class around the Windows Forms 2.0 WebBrowser control.
Stars: ✭ 72 (+7.46%)
Mutual labels:  wrapper
ssh2.nim
Async SSH, SCP and SFTP client for Nim, using libssh2 wrapper [WIP]
Stars: ✭ 17 (-74.63%)
Mutual labels:  wrapper
sagittarius
🎯 A set of javascript most used utils📑
Stars: ✭ 42 (-37.31%)
Mutual labels:  utils
Log
Breaking android log word limits and automatically formatting json.
Stars: ✭ 14 (-79.1%)
Mutual labels:  utils
pyGroff
laTEX is awesome but we are lazy -> groff with markdown syntax and inline code execution
Stars: ✭ 25 (-62.69%)
Mutual labels:  wrapper
tdesign-common
TDesign style/utils shared by multiple frameworks repo.
Stars: ✭ 70 (+4.48%)
Mutual labels:  utils
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-79.1%)
Mutual labels:  utils
AmniXTension
A Kotlin extensions + Utils library with Bunch of Help
Stars: ✭ 34 (-49.25%)
Mutual labels:  helper
caller-lookup
Reverse Caller Id using TrueCaller
Stars: ✭ 55 (-17.91%)
Mutual labels:  wrapper
pygmentize
Pygmentize is a wrapper to `pygmentize`, the command line interface provided by Pygments, a python syntax highlighter.
Stars: ✭ 25 (-62.69%)
Mutual labels:  wrapper
pscale-workflow-helper-scripts
Workflows and helper scripts around the PlanetScale DB workflow to automate database branch creation, association, update and merge directly out of your pull/merge request or favourite CI/CD.
Stars: ✭ 42 (-37.31%)
Mutual labels:  helper
popyt
A very easy to use Youtube Data v3 API wrapper.
Stars: ✭ 42 (-37.31%)
Mutual labels:  wrapper

Dotty-Dict

Info:Dictionary wrapper for quick access to deeply nested keys.
Author: Pawel Zadrozny @pawelzny <[email protected]>
CI Status Documentation Status PyPI Repository Status Release Status Project Status Supported python versions Supported interpreters License

Features

  • Simple wrapper around python dictionary and dict like objects
  • Two wrappers with the same dict are considered equal
  • Access to deeply nested keys with dot notation: dot['deeply.nested.key']
  • Create, read, update and delete nested keys of any length
  • Expose all dictionary methods like .get, .pop, .keys and other
  • Access dicts in lists by index dot['parents.0.first_name']
  • key=value caching to speed up lookups and low down memory consumption
  • support for setting value in multidimensional lists
  • support for accessing lists with slices

Installation

pip install dotty-dict

Documentation

TODO

Waiting for your feature requests ;)

Quick Example

Create new dotty using factory function.

>>> from dotty_dict import dotty
>>> dot = dotty({'plain': {'old': {'python': 'dictionary'}}})
>>> dot['plain.old']
{'python': 'dictionary'}

You can start with empty dotty

>>> from dotty_dict import dotty
>>> dot = dotty()
>>> dot['very.deeply.nested.thing'] = 'spam'
>>> dot
Dotty(dictionary={'very': {'deeply': {'nested': {'thing': 'spam'}}}}, separator='.', esc_char='\\')

>>> dot['very.deeply.spam'] = 'indeed'
>>> dot
Dotty(dictionary={'very': {'deeply': {'nested': {'thing': 'spam'}, 'spam': 'indeed'}}}, separator='.', esc_char='\\')

>>> del dot['very.deeply.nested']
>>> dot
Dotty(dictionary={'very': {'deeply': {'spam': 'indeed'}}}, separator='.', esc_char='\\')

>>> dot.get('very.not_existing.key')
None

NOTE: Using integer in dictionary keys will be treated as embedded list index.

Install for development

Install dev dependencies

$ make install

Testing

$ make test

Or full tests with TOX:

$ make test-all

Limitations

In some very rare cases dotty may not work properly.

  • When nested dictionary has two keys of different type, but with the same value. In that case dotty will return dict or list under random key with passed value.
  • Keys in dictionary may not contain dots. If you need to use dots, please specify dotty with custom separator.
  • Nested keys may not be bool type. Bool type keys are only supported when calling keys with type defined value (e.g. dot[True], dot[False]).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].