[Python-ideas] a in x or in y
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Feb 14 00:46:29 CET 2014
No language change required:
class either(object):
def __init__(self, *args):
self.args = args
def __contains__(self, x):
for a in self.args:
if x in a:
return True
return False
pocket = ['hankie', 'pocketknife', 'keys']
car = ['satchel', 'jacket', 'teddybear']
if 'keys' in either(car, pocket):
print("Found them")
else:
print("Lost them")
--
Greg
More information about the Python-ideas
mailing list