title: Using the key in collections.defaultdict
body: <p><a href="http://docs.python.org/library/collections.html#collections.defaultdict" rel="noreferrer"><code>collections.defaultdict</code></a> is great. Especially in conjunction with <code>lambda</code>:</p>
  
  <pre><code>&gt;&gt;&gt; import collections
  &gt;&gt;&gt; a = collections.defaultdict(lambda : [None,None])
  &gt;&gt;&gt; a['foo']
  [None, None]
  </code></pre>
  
  <p>Is there a way to use the key given (e.g. <code>'foo'</code>) in the lambda?  For example (doesn't work):</p>
  
  <pre><code>&gt;&gt;&gt; a = collections.defaultdict(lambda : [None]*key)
  &gt;&gt;&gt; a[1]
  [None]
  &gt;&gt;&gt; a[2]
  [None, None]
  &gt;&gt;&gt; a
  defaultdict(&lt;function &lt;lambda&gt; at 0x02984170&gt;, {1: [None], 2: [None, None]})
  </code></pre>