title: Can defaultdict accept callables dependent on the given missing key?
body: <p>The examples given in <a href="https://docs.python.org/3/library/collections.html#defaultdict-examples" rel="noreferrer">the docs</a> all seem to be the cases where the first callable argument in <code>defaultdict</code> is a "constant" function, like <code>int</code>, <code>list</code>, or <code>lambda: const</code> etc. I don't know if <code>defaultdict</code> is just supposed to take constant functions as its callabe argument, but if not, I want the callable to be dependent on the missing key values I give. For example</p>
  
  <pre><code>toy = collections.defaultdict(lambda x: len(x), {'foo': 3})
  toy['barr']
  </code></pre>
  
  <p>What I expect is whenever I give a missing key string, for example <code>'barr'</code>, the container can create a new entry with <code>'barr'</code> being the key and its length <code>4</code> being the value. But it doesn't work. Instead, it gives me the following error:</p>
  
  <pre><code>TypeError: &lt;lambda&gt;() missing 1 required positional argument: 'x'
  </code></pre>
  
  <p>I expected <code>'barr'</code> to be this <code>lambda</code>'s argument here, but it was apparently not the case. So what could have gone wrong?</p>