3
def in_sequence(x, seq):
11
>>> in_sequence(1, [1])
13
>>> in_sequence(1, (1,))
15
>>> in_sequence(1, {1:None})
18
>>> in_sequence(1, None) # doctest: +ELLIPSIS
19
Traceback (most recent call last):
20
TypeError: ...iterable...
22
>>> in_sequence(1, 1) # doctest: +ELLIPSIS
23
Traceback (most recent call last):
24
TypeError: ...iterable...
28
def not_in_sequence(x, seq):
30
>>> not_in_sequence(1, [])
32
>>> not_in_sequence(1, ())
34
>>> not_in_sequence(1, {})
36
>>> not_in_sequence(1, [1])
38
>>> not_in_sequence(1, (1,))
40
>>> not_in_sequence(1, {1:None})
43
>>> not_in_sequence(1, None) # doctest: +ELLIPSIS
44
Traceback (most recent call last):
45
TypeError: ...iterable...
47
>>> not_in_sequence(1, 1) # doctest: +ELLIPSIS
48
Traceback (most recent call last):
49
TypeError: ...iterable...
54
def in_dict(k, dict dct):
58
>>> in_dict(1, {1:None})
62
Traceback (most recent call last):
64
TypeError: 'NoneType' object is not iterable
68
def not_in_dict(k, dict dct):
70
>>> not_in_dict(1, {})
72
>>> not_in_dict(1, {1:None})
75
>>> not_in_dict(1, None)
76
Traceback (most recent call last):
78
TypeError: 'NoneType' object is not iterable
84
>>> cascaded(1, 2, 3) # doctest: +ELLIPSIS
85
Traceback (most recent call last):
87
TypeError: ...iterable...
88
>>> cascaded(-1, (1,2), (1,3))
90
>>> cascaded(1, (1,2), (1,3))
92
>>> cascaded(-1, (1,2), (1,0))