[PATCH] use 'x in dict' instead of 'dict.has_key(x)'

Benoit Boissinot bboissin at gmail.com
Tue Aug 25 06:02:29 CDT 2009


On Mon, Aug 24, 2009 at 11:48 PM, Alejandro Santos<alejolp at alejolp.com> wrote:
> On Mon, Aug 24, 2009 at 4:02 PM, Nicolas Dumazet<nicdumz at gmail.com> wrote:
>> # HG changeset patch
>> # User Nicolas Dumazet <nicdumz.commits at gmail.com>
>> # Date 1251140434 -7200
>> # Node ID 4a5253995fed8d0e45e025bb103016c66dbbed8d
>> # Parent  20ed9909dbd9251f76cacb463c480488eebf736b
>> use 'x in dict' instead of 'dict.has_key(x)'
>>
>> "in" is faster, and has_key will be removed in py3k
>>
>
> The 2to3 tool handles this simple fix automatically, among lots of other ones.

But it's more pythonic, (a bit) faster, and python 2.x already handles
it, so we have no
reason not to apply it, right?

regards,

Benoit



More information about the Mercurial-devel mailing list