Skip to content

dpath.get Empty List Path Yields Exception Rather Than Root Object #193

@squatched

Description

@squatched

I'm programmaticaly building out list paths and apparently, getting the root of the object with dpath.get() when using list paths is impossible.

For example:

x = {
    "a": {
        "b": {
            "3": 2,
            "43": 30,
            "c": [],
            "d": ['red', 'buggy', 'bumpers'],
        }
    }
}

# I would expect this to work but it gets a KeyError exception
dpath.get(x, []) == x

# This evaluates to True thanks to https://github.com/dpath-maintainers/dpath-python/issues/54
dpath.get(x, '/') == x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions