Skip to content

Commit

Permalink
Merge pull request dsc#4 from dsuch/master
Browse files Browse the repository at this point in the history
Made __contains__ correctly handle keys like None, True, False and similar
  • Loading branch information
dsc committed Feb 23, 2012
2 parents 5b068a0 + fab4fc9 commit 1812c22
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bunch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ def __contains__(self, k):
>>> b.hello = 'hai'
>>> 'hello' in b
True
>>> b[None] = 123
>>> None in b
True
>>> b[False] = 456
>>> False in b
True
"""
try:
return hasattr(self, k) or dict.__contains__(self, k)
return dict.__contains__(self, k) or hasattr(self, k)
except:
return False

Expand Down

0 comments on commit 1812c22

Please sign in to comment.