Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
Created February 24, 2014 08:27
Show Gist options
  • Select an option

  • Save flaneur2020/9183845 to your computer and use it in GitHub Desktop.

Select an option

Save flaneur2020/9183845 to your computer and use it in GitHub Desktop.
>>> from collections import defaultdict
>>> d = defaultdict(lambda: [])
>>> d
defaultdict(<function <lambda> at 0x1004999b0>, {})
>>> d['a'].append(1)
>>> d
defaultdict(<function <lambda> at 0x1004999b0>, {'a': [1]})
>>> d['b']
[]
>>> d
defaultdict(<function <lambda> at 0x1004999b0>, {'a': [1], 'b': []})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment