Skip to content

Commit 6213399

Browse files
authored
Merge pull request satwikkansal#292 from jeffreykennethli/master
Update link and add parenthesis to chained operators section
2 parents e9a49a5 + d3a25fa commit 6213399

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,15 @@ False
384384
385385
#### 💡 Explanation:
386386
387-
As per https://docs.python.org/3/reference/expressions.html#membership-test-operations
387+
As per https://docs.python.org/3/reference/expressions.html#comparisons
388388
389389
> Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN are comparison operators, then a op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... y opN z, except that each expression is evaluated at most once.
390390
391391
While such behavior might seem silly to you in the above examples, it's fantastic with stuff like `a == b == c` and `0 <= x <= 100`.
392392
393393
* `False is False is False` is equivalent to `(False is False) and (False is False)`
394-
* `True is False == False` is equivalent to `True is False and False == False` and since the first part of the statement (`True is False`) evaluates to `False`, the overall expression evaluates to `False`.
395-
* `1 > 0 < 1` is equivalent to `1 > 0 and 0 < 1` which evaluates to `True`.
394+
* `True is False == False` is equivalent to `(True is False) and (False == False)` and since the first part of the statement (`True is False`) evaluates to `False`, the overall expression evaluates to `False`.
395+
* `1 > 0 < 1` is equivalent to `(1 > 0) and (0 < 1)` which evaluates to `True`.
396396
* The expression `(1 > 0) < 1` is equivalent to `True < 1` and
397397
```py
398398
>>> int(True)

0 commit comments

Comments
 (0)