In python, is it possible to generate a value for a defaultdict which is a function of the key? For example: from collections import defaultdict d = defaultdict(lambda key=None: key * 2) so that d[1] will produces the value 2. Continue reading...