From: news at dorb.com (Darrell)
Date: Thu, 22 Apr 1999 20:16:51 -0400
Subject: try vs. has_key()
References: <aahzFAM4oJ.M7M@netcom.com>
Message-ID: <yWOT2.6007$8m5.9320@newsr1.twcny.rr.com>
X-UID: 1557                                                  

My experience shows that throwing an exception is slower.

Aahz Maruch <aahz at netcom.com> wrote in message
news:aahzFAM4oJ.M7M at netcom.com...
> 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






