Sorry, Kirby, I'm afraid I disagree. try: res_dict[ext] += 1 except KeyError: res_dict[ext] = 1 is clear in intent and operation. It is a self-initializing occurrence counter.
On the other hand, res_dict[ext] = res_dict.get(ext, 0) + 1 is obscure. Unless I go dig up the documentation of what the .get() operation does on a dictionary, I have no idea what the intention of the code is -- and I am (humbly) a very experienced programmer and Python programmer. Also I doubt whether the one-line version is faster. Without looking at the code, I would bet that .get() is implemented using a try / except structure. There is nothing wrong with that. Remember the Zen of Python: >>>import this ... Readability counts. ... -- Vernon _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig