Hacker News new | ask | show | jobs
by andreasvc 3858 days ago
The easiest is to never use .keys() or .iterkeys(), and always iterate over the bare dict:

    for k in dict:
        ...

    if k in dict:
        ...
If you do need a list of keys, list(dict) has the advantage of working in both Python 2 and 3.