dict-deep | simple deep_set and deep_get functions | JSON Processing library

 by   mbello Python Version: 4.1.2 License: MIT

kandi X-RAY | dict-deep Summary

kandi X-RAY | dict-deep Summary

dict-deep is a Python library typically used in Utilities, JSON Processing applications. dict-deep has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install dict-deep' or download it from GitHub, PyPI.

Simple functions to set or get values from a nested dict structure or in fact a deep structure of any object, because since version 2 we no longer assume we are dealing with dicts. You may use a custom accessor or pass your own getter, setter, deleter callables so that you can traverse a nested structure of any kind of object. This module DOES NOT implement dotted notation as an alternative access method for dicts. I generally do not like changing python dicts to enable dot notation, hence no available package fitted my needs for a simple deep accessor. NEW IN VERSION 4: Since version 3 we make no assumption that we are dealing with dicts, so you can have your nested structure of any type. However, in version 4 we reintroduce better defaults so that for those that are indeed working with nested dicts the default values shall be enough without having to define an accessor or a getter. Notes: With deep_get, you could use 'lambda o, k: o[k]' or 'lambda o, k: o.get(k)' as either the getter or the accessor. The only 'special' thing about the 'getter' function is that when it is invoked with 'o' being a list, it will instead iterate over the list and call the accessor for each item in the list.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              dict-deep has a low active ecosystem.
              It has 9 star(s) with 0 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 2 have been closed. On average issues are closed in 8 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of dict-deep is 4.1.2

            kandi-Quality Quality

              dict-deep has no bugs reported.

            kandi-Security Security

              dict-deep has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              dict-deep is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              dict-deep releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed dict-deep and discovered the below as its top functions. This is intended to give you an instant insight into dict-deep implemented functionality, and help decide if they suit your requirements.
            • Helper function for deep get .
            • Creates a function to remove a value from a dictionary .
            • Creates a setter for the given setter .
            • Deep setter for key value pairs .
            • Helper function for deep delete .
            • Wrapper for getter .
            • Wrapper for getter .
            • Return a list of keys .
            Get all kandi verified functions for this library.

            dict-deep Key Features

            No Key Features are available at this moment for dict-deep.

            dict-deep Examples and Code Snippets

            Example / Usage
            Pythondot img1Lines of Code : 74dot img1License : Permissive (MIT)
            copy iconCopy
            from dict_deep import deep_get, deep_set, deep_del
            
            
            i = 0
            
            # 1
            i += 1
            o = {'a': {'b': {}}}
            deep_set(o, "a.b.c", "Hello World")
            print("{}: {}".format(i, deep_get(o, "a.b.c")))
            
            # 2
            i += 1
            o = {}
            deep_set(o, ['a', 'b', 'c'], "Hello World")
            print("{}:   
            Description
            Pythondot img2Lines of Code : 23dot img2License : Permissive (MIT)
            copy iconCopy
            for k in keys[:-1]:
                if o is None:
                    return o
                o = getter(o, k)
            
            o = getter_last_step(o, keys[-1])
            
            return o
            
            def __default_getter(o, k):
                if isinstance(o, list):
                    return [accessor(i, k) for i in o]
                else:
                    return acce  
            Sending python dictionary path as variable
            Pythondot img3Lines of Code : 77dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # - this one is recursive
            def f(vars,d):
                if not vars:
                    return d
                d = d[vars[0]]
                return f(vars[1:],d)
            
            # - "normal" iteration
            def g(vars,d):
                vars = iter(vars)
                val = d[next(vars)]
                for item in vars:
                    val =

            Community Discussions

            Trending Discussions on dict-deep

            QUESTION

            Sending python dictionary path as variable
            Asked 2020-Nov-29 at 16:32

            this or similar to was maybe asked in the past but I couldn't find a solution to suit my case. I currently have this following dict:

            ...

            ANSWER

            Answered 2020-Nov-29 at 16:32

            how can I send test_var_2 as a path variable

            Write a function to iteratively work through the path.

            Source https://stackoverflow.com/questions/65061384

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install dict-deep

            You can install using 'pip install dict-deep' or download it from GitHub, PyPI.
            You can use dict-deep like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install dict-deep

          • CLONE
          • HTTPS

            https://github.com/mbello/dict-deep.git

          • CLI

            gh repo clone mbello/dict-deep

          • sshUrl

            git@github.com:mbello/dict-deep.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular JSON Processing Libraries

            json

            by nlohmann

            fastjson

            by alibaba

            jq

            by stedolan

            gson

            by google

            normalizr

            by paularmstrong

            Try Top Libraries by mbello

            memory-tempfile

            by mbelloPython

            ezprinting

            by mbelloPython

            aio-odoorpc

            by mbelloPython

            aio-odoorpc-base

            by mbelloPython