#26 warn on dict.has_key[value]

open
nobody
None
5
2005-01-27
2005-01-27
Adrian Likins
No

At least for me, a pretty common typo is something
like:

dict = {}
dict['blippy'] = 'baz'

if dict.has_key['blippy']:
whatever

aka, using [] for has_key instead of proper ()

Discussion

  • Neal Norwitz
    Neal Norwitz
    2005-01-27

    Logged In: YES
    user_id=33168

    Adrian, I think this is a good idea. I'm a little surprised
    this isn't already handled. I'll have to look.

    Are you guys coming to PyCon this year? Hope everyone can
    make it.