1.1 --- a/lib/__builtins__/list.py Tue Nov 29 17:27:31 2016 +0100
1.2 +++ b/lib/__builtins__/list.py Tue Nov 29 17:29:42 2016 +0100
1.3 @@ -39,7 +39,6 @@
1.4 if args is not None:
1.5 self.extend(args)
1.6
1.7 - def __contains__(self, value): pass
1.8 def __delitem__(self, index): pass
1.9 def __setslice__(self, start, end, slice): pass
1.10 def __delslice__(self, start, end): pass
2.1 --- a/lib/__builtins__/sequence.py Tue Nov 29 17:27:31 2016 +0100
2.2 +++ b/lib/__builtins__/sequence.py Tue Nov 29 17:29:42 2016 +0100
2.3 @@ -46,6 +46,22 @@
2.4
2.5 return str(b)
2.6
2.7 + def __contains__(self, value):
2.8 +
2.9 + "Return whether the list contains 'value'."
2.10 +
2.11 + # Perform a linear search of the sequence contents.
2.12 +
2.13 + for v in self:
2.14 +
2.15 + # Return True if the current value is equal to the specified one.
2.16 + # Note that this is not an identity test, but an equality test.
2.17 +
2.18 + if v == value:
2.19 + return True
2.20 +
2.21 + return False
2.22 +
2.23 def __getitem__(self, index):
2.24
2.25 "Return the item or slice specified by 'index'."
3.1 --- a/tests/list.py Tue Nov 29 17:27:31 2016 +0100
3.2 +++ b/tests/list.py Tue Nov 29 17:29:42 2016 +0100
3.3 @@ -24,3 +24,12 @@
3.4 print l[-5] # should raise an exception
3.5 except IndexError, exc:
3.6 print "l[-5]: failed with argument", exc.index
3.7 +
3.8 +print 1 in l # True
3.9 +print 4 in l # False
3.10 +print "four" in l # True
3.11 +print "one" in l # False
3.12 +print 1 not in l # False
3.13 +print 4 not in l # True
3.14 +print "four" not in l # False
3.15 +print "one" not in l # True
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tests/operator_syntax.py Tue Nov 29 17:29:42 2016 +0100
4.3 @@ -0,0 +1,4 @@
4.4 +print 1 == 1 # True
4.5 +print 1 != 1 # False
4.6 +print 1 == "one" # False
4.7 +print 1 != "one" # True