7 ms·
Your implementation suffer from a bug, if the final item is None it will return the default instead of None. A better implementation would be: def rget(d,
by staz 9y ago
Your implementation suffer from a bug, if the final item is None it will return the default instead of None.
A better implementation would be:
def rget(d, *ks, **kwargs):
for k in ks:
if k not in d:
return kwargs.get('default')
d = d[k]
return d