class a(object):
def a(self):
return True
__contains__=a
b=a()
print 2 in b#why error
class a(object): def a(self): return True __contains__=a b=a() print 2 in b#why error
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
__contains__is meant to take an argument.adoesn’t accept an argument.The following is your example with a working
__contains__: