python dict setdefault, confused
<p>New to python.  I was looking at an algorithm today and I can't figure out why the dict d has values in it and curr does not.  To me it does not seem like anything is being done to dict d.</p>

<pre><code>&gt;&gt;&gt; def what(*words):
...     d = dict()
...     print d
...     for word in words:
...     print 'word: ' + word
...         curr = d
...         for letter in word:
...             curr = curr.setdefault(letter, {})
...         curr = curr.setdefault('.', '.')
...     print d
...     print '?'
...     print curr
...     return 1
... 
&gt;&gt;&gt; what('foo') 
{}
word: foo
{'f': {'o': {'o': {'.': '.'}}}}
?
.
1
</code></pre>
