2005/02/14
I have been reading up on Trie data structures, inspired by some Python Trie code from James Tauber. In there he uses the .setdefault method on the dicts, and it threw me the first time I read it. Huh? Disgrace! Yes, I have never used it, whil it would have been very useful to me in lots of code snippets elsewhere. Oh well, never too late to learn. I know have this idiom in my head and will gratefully use it.
Thanks to this useful discussion of the matter by Jarno Virtanen, it became a lot clearer to me. And BTW, I agree that on first seeing it, the meaning is not clear, but once you know it, the usage is very succint.
