On 2016-10-19 03:15, chenyong20...@gmail.com wrote:
Thanks Peter and Anssi for your kind help. Now I'm ok with the first question. But 
the second question still confused me. Why "it seems that
after root = root.setdefault(ch,{}) tree['a'] and root are the same
object" and follows tree['a']['b']? Thanks.

You call the .setdefault method with a key and a default value.

The .setdefault method does this: if the key is in the dict, it returns the associated value, else it puts the key and the default into the dict and then returns the default.


Reply via email to