remove has_key (not working in python3)
This commit is contained in:
parent
882316c298
commit
cc9fff9840
19 changed files with 182 additions and 183 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue