Skip to content

nripankadas07/dotpath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotpath

Dotted-key get/set/has/del over nested dicts and lists. Zero deps.

from dotpath import get, set_, has, delete, paths

d = {"users": [{"name": "alice"}, {"name": "bob"}]}
get(d, "users.1.name")            # 'bob'
get(d, "users.5.name", default=None)  # None

set_(d, "users.0.email", "a@x")
# {"users": [{"name": "alice", "email": "a@x"}, {"name": "bob"}]}

has(d, "users.0.email")           # True
delete(d, "users.0.email")
list(paths(d))                     # ['users.0.name', 'users.1.name']

\\. escapes a literal dot inside a key segment. List indices are integers; negatives count from the end.

MIT.

About

Dotted-key get/set/has/del over nested dicts and lists, like jq's path syntax minus the language. Zero dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages