Skip to content

Commit

Permalink
fixes #639
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Oct 14, 2024
1 parent 2649d6e commit f98ed33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fastcore/xtras.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _expand_import(node, mod, existing):
# %% ../nbs/03_xtras.ipynb
def dict2obj(d, list_func=L, dict_func=AttrDict):
"Convert (possibly nested) dicts (or lists of dicts) to `AttrDict`"
if isinstance(d, (L,list)): return list_func(map(dict2obj, d))
if isinstance(d, (L,list)): return list_func([dict2obj(v, list_func=list_func, dict_func=dict_func) for v in d])
if not isinstance(d, dict): return d
return dict_func(**{k:dict2obj(v, list_func=list_func, dict_func=dict_func) for k,v in d.items()})

Expand Down
2 changes: 1 addition & 1 deletion nbs/03_xtras.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@
"#|export\n",
"def dict2obj(d, list_func=L, dict_func=AttrDict):\n",
" \"Convert (possibly nested) dicts (or lists of dicts) to `AttrDict`\"\n",
" if isinstance(d, (L,list)): return list_func(map(dict2obj, d))\n",
" if isinstance(d, (L,list)): return list_func([dict2obj(v, list_func=list_func, dict_func=dict_func) for v in d])\n",
" if not isinstance(d, dict): return d\n",
" return dict_func(**{k:dict2obj(v, list_func=list_func, dict_func=dict_func) for k,v in d.items()})"
]
Expand Down

0 comments on commit f98ed33

Please sign in to comment.