I am looking to create a simple nested \"lookup\" mechanism in python, and wanted to make sure there wasn\'t already something somewhere hidden in the vast libraries in pyth
Recursion still works.
def walk_into( dict, key ): head, _, tail = key.partition('.') if tail: return walk_into( dict[head], tail ) return dict, key d, k = walk_into( my_dict, "root.secondary.user2" )
d[k] can be used for getting or putting a new value.
d[k]