try vs. has_key()
Aahz Maruch
aahz at netcom.com
Thu Apr 22 18:48:19 EDT 1999
I've seen roughly half the people here doing
try:
dict[key].append(foo)
except:
dict[key]=[foo]
with the other half doing
if dict.has_key(key):
dict[key].append(foo)
else:
dict[key]=[foo]
Can people explain their preferences?
--
--- Aahz (@netcom.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het
"You often don't really understand the problem until after the first
time you implement a solution." - Eric S. Raymond
More information about the Python-list
mailing list