Sunday, 6 January 2019

Should I use 'has_key()' or 'in' on Python dicts?

I wonder what is better to do:

d = {'a': 1, 'b': 2}
'a' in d
True

or:

d = {'a': 1, 'b': 2}
d.has_key('a')
True



from Should I use 'has_key()' or 'in' on Python dicts?

No comments:

Post a Comment