Need a method to convert app.storage
Observables to builtin datatypes
#4431
amks1
started this conversation in
Ideas / Feature Requests
Replies: 1 comment
-
Thanks for the suggestion, @amks1! data = observables.ObservableDict({
'a': 1,
'b': [1, 2, 3, {'x': 1, 'y': 2, 'z': 3}],
'c': {'x': 1, 'y': 2, 'z': 3, 't': [1, 2, 3]},
'd': {1, 2, 3},
})
def extract(data):
if isinstance(data, observables.ObservableDict):
return {k: extract(v) for k, v in data.items()}
if isinstance(data, observables.ObservableList):
return [extract(v) for v in data]
if isinstance(data, observables.ObservableSet):
return {extract(v) for v in data}
return data
print(extract(data))
I just wonder how to add correct type annotation. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
I have a specific use case where I need to pickle and unpickle the storage data (specifically,
app.storage.client
) usingdill
.dill.loads()
throws this error:ObservableCollection seems to recursively convert all inner dicts, lists, sets, etc into ObservableCollection datatypes. Can we have a method to convert them back into python builtin datatypes and get back the original data that was stored in them? In my case I don't need to modify the storage after unpickling.
Beta Was this translation helpful? Give feedback.
All reactions