Skip to content

Commit

Permalink
Fix wrong in operator wrong behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Oliveira committed Nov 20, 2017
1 parent 34eedf5 commit 925bb9d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bunch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ def __contains__(self, k):
>>> b[False] = 456
>>> False in b
True
>>> 'items' in b, 'keys' in b, 'values' in b
(False, False, False)
>>> b['values']
Traceback (most recent call last):
File "<doctest bunch.Bunch.__contains__[12]>", line 1, in <module>
b['values']
KeyError: 'values'
>>> b.values # doctest: +ELLIPSIS
<built-in method values of Bunch object at ...>
"""
try:
return dict.__contains__(self, k) or hasattr(self, k)
except:
return False
return dict.__contains__(self, k)

# only called if k not found in normal places
def __getattr__(self, k):
Expand Down

0 comments on commit 925bb9d

Please sign in to comment.