You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
nested_alter fails to update elements deep in the hierarchy if the structure of the hierarchy higher up has been altered in the same call. Example:
fromnested_lookupimportnested_alterdefrename_subkeys(data):
try:
data['renamed'] =data.pop('rename me')
exceptKeyError:
passreturndatadocument= {'key': {'rename me': 1}, 'sub': {'key': {'rename me': 1}}}
altered_document=nested_alter(document, 'key', rename_subkeys)
# The above call works, since renaming the first key doesn't alter how the second key is accessed. Result:# {'key': {'renamed': 1}, 'sub': {'key': {'renamed': 1}}}document= {'key': {'rename me': {'rename me': 1}}}
altered_document=nested_alter(document, 'key', rename_subkeys)
# This does not work, only one of the keys are renamed. Result: # {'key': {'renamed': {'rename me': 1}}}
The text was updated successfully, but these errors were encountered:
nested_alter fails to update elements deep in the hierarchy if the structure of the hierarchy higher up has been altered in the same call. Example:
The text was updated successfully, but these errors were encountered: