utility method clean does not work for nested dicts #382
martinius74
started this conversation in
Ideas
Replies: 1 comment
-
@martinius74 nice catch, I agree this should be the default behaviour, thank you for reporting this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying to clean my nested dictionaries from any empty string and collections, but somehow, it only considers the root level.
Nested keys are not cleaned.
Looking into the code, the method is using the keys() method.
def clean(d, strings=True, collections=True):
keys = list(d.keys())
If we would use the keypaths() method, it would be able to find all nested keys as well:
def clean(d, strings=True, collections=True):
keys = d.keypaths()
Would it make sense to change this behaviour?
Beta Was this translation helpful? Give feedback.
All reactions