Answers for "python create defaultdict from dict"

1

python defaultdict to dict

>>> #You can simply call dict:
>>> a
defaultdict(<type 'list'>, {'1': ['b', 'a'], '3': ['b'], '2': ['a']})
>>> dict(a)
{'1': ['b', 'a'], '3': ['b'], '2': ['a']}

# but remember that a defaultdict is a dict
# (with some special behavior, check source):
>>> isinstance(a, dict)
True
Posted by: Guest on October-13-2020

Code answers related to "python create defaultdict from dict"

Python Answers by Framework

Browse Popular Code Answers by Language