Skip to content

Instantly share code, notes, and snippets.

View mannyanebi's full-sized avatar
🔥
Stay Awesome!

Emmanuel Anebi mannyanebi

🔥
Stay Awesome!
View GitHub Profile
@mannyanebi
mannyanebi / object_to_dict_recursive.py
Created August 24, 2023 23:25 — forked from sairamkrish/object_to_dict_recursive.py
Python object to dictionary - recursively convert
'''
Generic object to dict converter. Recursively convert.
Useful for testing and asserting objects with expectation.
'''
def todict(obj, classkey=None):
if isinstance(obj, dict):
data = {}
for (k, v) in obj.items():
data[k] = todict(v, classkey)