Hacker News new | ask | show | jobs
by bayareaguy 6701 days ago
If missing variables are an issue you could use defaultdict.

http://docs.python.org/lib/defaultdict-objects.html

1 comments

Good point, and thanks for pointing out defaultdict(); I wasn't even aware of that class. I suppose one could use defaultdict() to gain associativity also (pass 'not found' variables through unmodified). I think I still slightly prefer replace(), for uninteresting reasons.