__contains__()

John Schmitt jschmitt at vmlabs.com
Wed Feb 14 22:46:19 EST 2001


I did something a little cheezy.

>>>class foo:
       def __contains__(self,n):
           return 42

>>>f = foo()

>>>3 in f
1

I thought I would get back 42.  The manual doesn't say that it must strictly
return 0 or 1, just something true or false.

I wonder what the PSU has to say about this.  How does one become a memb




More information about the Python-list mailing list