remove has_key (not working in python3)

This commit is contained in:
Tomas Kopecek 2017-03-01 14:57:06 +01:00 committed by Mike McLean
parent 882316c298
commit cc9fff9840
19 changed files with 182 additions and 183 deletions

View file

@ -135,7 +135,7 @@ def dslice(dict, keys, strict=True):
"""Returns a new dictionary containing only the specified keys"""
ret = {}
for key in keys:
if strict or dict.has_key(key):
if strict or key in dict:
#for strict we skip the has_key check and let the dict generate the KeyError
ret[key] = dict[key]
return ret
@ -144,7 +144,7 @@ def dslice_ex(dict, keys, strict=True):
"""Returns a new dictionary with only the specified keys removed"""
ret = dict.copy()
for key in keys:
if strict or ret.has_key(key):
if strict or key in ret:
del ret[key]
return ret