Skip to content

chrisantonellis/delimited

Repository files navigation

Delimited

Travis Coveralls github PyPI Somethin

Delimited defines classes that allow for accessing and modifying nested data.

Installation

pip install delimited

Documentation

https://chrisantonellis.github.io/delimited/

Abstract

Nested data can be easily expressed in python but not easily accessed or modified. Using builtin methods, accessing nested data requires chaining dict.get() calls.

  mydict = {
    "key1": {
      "key2": {
        "key3": "value"
      }
    }
  }

  mydict.get("key1", {}).get("key2", {}).get("key3", {})

This is overly verbose and lacks the functionality needed to effectively interact with the data. Delimited provides classes that emulate native types and make accessing and modifying nested data easier.

  from delimited import DelimitedDict as ddict
  
  mydict = ddict({
    "key1": {
      "key2": {
        "key3": "value"
      }
    }
  })

  mydict.get("key1.key2.key3")
  # returns "value"
  
  mydict.collapse()
  # returns {"key1.key2.key3": "value"}

Delimited provides Path classes to represent paths to nested data using tuples or strings, and NestedContainer classes that emulate the native dict type. Check out the documentation to learn more.

About

Delimited defines classes that allow for accessing and modifying nested data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages