Message info From:Georg Brandl Subject:Re: [Python-checkins] cpython (2.7): Closes #14306: clarify expensiveness of try-except and update code snippet Date:Sun, 18 Mar 2012 16:03:06 +0100

On 03/18/2012 02:49 PM, Nick Coghlan wrote:
> On Sun, Mar 18, 2012 at 1:58 AM, georg.brandl
> <> wrote:
>> +catching an exception is expensive. In versions of Python prior to 2.0 it was
>> +common to use this idiom::
> Actually, given the "prior to 2.0" caveat, "mydict.has_key(key)" is
> right: the "key in mydict" version was only added in 2.2.
> This answer probably needs more improvements than just modernising the
> example that is already there.

Yep. I also wondered what was left out, since the past tense "was common..."
suggests that something is missing. But for the moment I just wanted to get
rid of legacy code that might induce people to use has_key().


Python-checkins mailing list