title: python defaultdict: 0 vs. int and [] vs list
body: <p>Is there any difference between passing <code>int</code> and <code>lambda: 0</code> as arguments? Or between <code>list</code> and <code>lambda: []</code>?</p>
  
  <p>It looks like they do the same thing:</p>
  
  <pre><code>from collections import defaultdict
  dint1 = defaultdict(lambda: 0)
  dint2 = defaultdict(int)
  dlist1 = defaultdict(lambda: [])
  dlist2 = defaultdict(list)
  
  for ch in 'abracadabra':
      dint1[ch] += 1
      dint2[ch] += 1
      dlist1[ch].append(1)
      dlist2[ch].append(1)
  
  print dint1.items()
  print dint2.items()
  print dlist1.items()
  print dlist2.items()
  ## -- Output: --
  [('a', 5), ('r', 2), ('b', 2), ('c', 1), ('d', 1)]
  [('a', 5), ('r', 2), ('b', 2), ('c', 1), ('d', 1)]
  [('a', [1, 1, 1, 1, 1]), ('r', [1, 1]), ('b', [1, 1]), ('c', [1]), ('d', [1])]
  [('a', [1, 1, 1, 1, 1]), ('r', [1, 1]), ('b', [1, 1]), ('c', [1]), ('d', [1])]
  </code></pre>
  
  <p>but are there any cases where they'll have different behavior, or is it merely a notational difference?</p>