If for whatever reason you need a function returning a dictionary from a defaultdict, you can simply convert it that way:
from collections import defaultdict default_int_dict = defaultdict(int) default_int_dict['a'] += 1 assert type(default_int_dict) is defaultdict converted_default_dict = dict(default_int_dict) assert type(converted_default_dict) is dict