@@ -1271,28 +1271,29 @@ Membership test operations
1271
1271
--------------------------
1272
1272
1273
1273
The operators :keyword: `in ` and :keyword: `not in ` test for membership. ``x in
1274
- s `` evaluates to true if *x * is a member of *s *, and false otherwise. `` x not
1275
- in s `` returns the negation of ``x in s ``. All built-in sequences and set types
1276
- support this as well as dictionary, for which :keyword: `in ` tests whether the
1277
- dictionary has a given key. For container types such as list, tuple, set ,
1278
- frozenset, dict, or collections.deque, the expression ``x in y `` is equivalent
1274
+ s `` evaluates to `` True `` if *x * is a member of *s *, and `` False `` otherwise.
1275
+ `` x not in s `` returns the negation of ``x in s ``. All built-in sequences and
1276
+ set types support this as well as dictionary, for which :keyword: `in ` tests
1277
+ whether the dictionary has a given key. For container types such as list, tuple,
1278
+ set, frozenset, dict, or collections.deque, the expression ``x in y `` is equivalent
1279
1279
to ``any(x is e or x == e for e in y) ``.
1280
1280
1281
- For the string and bytes types, ``x in y `` is true if and only if *x * is a
1281
+ For the string and bytes types, ``x in y `` is `` True `` if and only if *x * is a
1282
1282
substring of *y *. An equivalent test is ``y.find(x) != -1 ``. Empty strings are
1283
1283
always considered to be a substring of any other string, so ``"" in "abc" `` will
1284
1284
return ``True ``.
1285
1285
1286
1286
For user-defined classes which define the :meth: `__contains__ ` method, ``x in
1287
- y `` is true if and only if ``y.__contains__(x) `` is true.
1287
+ y `` returns ``True `` if ``y.__contains__(x) `` returns a true value, and
1288
+ ``False `` otherwise.
1288
1289
1289
1290
For user-defined classes which do not define :meth: `__contains__ ` but do define
1290
- :meth: `__iter__ `, ``x in y `` is true if some value ``z `` with ``x == z `` is
1291
+ :meth: `__iter__ `, ``x in y `` is `` True `` if some value ``z `` with ``x == z `` is
1291
1292
produced while iterating over ``y ``. If an exception is raised during the
1292
1293
iteration, it is as if :keyword: `in ` raised that exception.
1293
1294
1294
1295
Lastly, the old-style iteration protocol is tried: if a class defines
1295
- :meth: `__getitem__ `, ``x in y `` is true if and only if there is a non-negative
1296
+ :meth: `__getitem__ `, ``x in y `` is `` True `` if and only if there is a non-negative
1296
1297
integer index *i * such that ``x == y[i] ``, and all lower integer indices do not
1297
1298
raise :exc: `IndexError ` exception. (If any other exception is raised, it is as
1298
1299
if :keyword: `in ` raised that exception).
0 commit comments