Guido van Rossum wrote: > Over lunch with Alex Martelli, he proposed that a subclass of dict > with this behavior (but implemented in C) would be a good addition to > the language. It looks like it wouldn't be hard to implement. It could > be a builtin named defaultdict. The first, required, argument to the > constructor should be the default value. Remaining arguments (even > keyword args) are passed unchanged to the dict constructor. > > Feedback?
On behalf of everyone who has answered this question on c.l.py, may I say WOOHOO! FWIW, my usual spelling is: try: v = d[key] except: v = d[key] = value which breaks the principle of "write it once". Tim Delaney _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com