Skip to content

Commit 4aba506

Browse files
committed
-
1 parent 3577176 commit 4aba506

File tree

1 file changed

+8
-0
lines changed
  • source_py3/python_toolbox/combi

1 file changed

+8
-0
lines changed

source_py3/python_toolbox/combi/perm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,20 @@ def __init__(self, number_or_perm_sequence, perm_space=None):
125125
__int__ = lambda self: self.number
126126
__mod__ = lambda self, other: self.number % other
127127
__iter__ = lambda self: iter(self._perm_sequence)
128+
128129
__eq__ = lambda self, other: (isinstance(other, Perm) and
129130
self._reduced == other._reduced)
130131
__ne__ = lambda self, other: not (self == other)
131132
__hash__ = lambda self: hash(self._reduced)
132133
__bool__ = lambda self: bool(self._perm_sequence)
133134

135+
def __contains__(self, item):
136+
try:
137+
return (item in self._perm_sequence)
138+
except TypeError:
139+
# Gotta have this `except` because Python complains if you try `1
140+
# in 'meow'`.
141+
return False
134142

135143
def __repr__(self):
136144
if self.just_dapplied_rapplied_perm_space.length == infinity:

0 commit comments

Comments
 (0)