The pick_by_path function is used to extract values from nested dictionaries using a path-like string to identify the desired value. The function takes three arguments: a dictionary object, a string representing the path to the desired value and optionally a delimiter.
The path string consists of a sequence of keys, separated by the delimiter character ('/' by default), where each key represents a level in the nested dictionary. If the key has the value '*', it matches any key on that level, or sets it to check all items in the list.
The function returns the value at the end of the path or a list of values if the path contains a wildcard. If the path is not found, the function returns None.
obj -- A dictionary object to search for the desired value.
path: str -- A string representing the path to the desired value.
delimiter: str -- A string used to separate keys in the path string. Default is "/".
Return value:
Returns the value found at the end of the path string, or a list of values if the path contains a wildcard. If the path is not found, None is returned.
pick_by_paths
The pick_by_paths function is similar to pick_by_path, but can extract values from multiple paths at once. It takes a dictionary object and a list of path strings as arguments, and returns a list of values found at the end of each path string or None if a path is not found. This works faster than running pick_by_path in a loop.
We found that dict-picker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.