Skip to content

Commit eb342ea

Browse files
committed
review suggestions
1 parent 2c0d4f9 commit eb342ea

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

Lib/operator.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
This is the pure Python implementation of the module.
1111
"""
1212

13-
__all__ = ['abs', 'add', 'and_', 'attrgetter', 'call', 'concat',
14-
'in_', 'not_in', 'contains', 'countOf',
13+
__all__ = ['abs', 'add', 'and_', 'attrgetter', 'call', 'concat', 'contains', 'countOf',
1514
'delitem', 'eq', 'floordiv', 'ge', 'getitem', 'gt', 'iadd', 'iand',
16-
'iconcat', 'ifloordiv', 'ilshift', 'imatmul', 'imod', 'imul',
15+
'iconcat', 'ifloordiv', 'ilshift', 'imatmul', 'imod', 'imul', 'in_',
1716
'index', 'indexOf', 'inv', 'invert', 'ior', 'ipow', 'irshift',
1817
'is_', 'is_not', 'isub', 'itemgetter', 'itruediv', 'ixor', 'le',
1918
'length_hint', 'lshift', 'lt', 'matmul', 'methodcaller', 'mod',
20-
'mul', 'ne', 'neg', 'not_', 'or_', 'pos', 'pow', 'rshift',
19+
'mul', 'ne', 'neg', 'not_', 'not_in', 'or_', 'pos', 'pow', 'rshift',
2120
'setitem', 'sub', 'truediv', 'truth', 'xor']
2221

2322
from builtins import abs as _abs
@@ -151,22 +150,18 @@ def concat(a, b):
151150
raise TypeError(msg)
152151
return a + b
153152

154-
155153
def in_(a, b):
156154
"Same as a in b."
157155
return a in b
158156

159-
160157
def not_in(a, b):
161158
"Same as a not in b."
162159
return a not in b
163160

164-
165161
def contains(a, b):
166162
"Same as b in a (note reversed operands)."
167163
return b in a
168164

169-
170165
def countOf(a, b):
171166
"Return the number of items in a which are, or which equal, b."
172167
count = 0
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
:func:`operator.in_` and :func:`operator.not_in` added to ``operator`` module.
1+
Add :func:`operator.in_` and :func:`operator.not_in` to the :mod:`operator` module.

Modules/_operator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ _operator_not_in_impl(PyObject *module, PyObject *a, PyObject *b)
507507
{
508508
int result = PySequence_Contains(b, a);
509509
if (result != -1) {
510-
result = 1 - result;
510+
result = !result;
511511
}
512512
return result;
513513
}

0 commit comments

Comments
 (0)