try vs. has_key()

Charles G Waldman cgw at fnal.gov
Thu Apr 22 22:47:43 EDT 1999


Personally I really like the new-ish "get" method of dictionaries, which lets you write

 dict[key] = dict.get(key,[]) + [foo]

I don't know about performance implications but it's a nice terse construct.





More information about the Python-list mailing list