diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index a304269..f437601 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -175,8 +175,8 @@ h3:before{counter-increment:h3;content:'A.' counter(h2) '.' counter(h3) '. '}
  1. The simplest form. -
  2. The or operator takes precedence over the in operator, so there is no need for parentheses around (x in a_dictionary) or (y in a_dictionary). -
  3. On the other hand, you do need parentheses around (x or y) here, for the same reason — or takes precedence over in. (Note: this code is completely different from the previous line. Python interprets x or y first, which results in either x (if x is true in a boolean context) or y. Then it takes that singular value and checks whether it is a key in a_dictionary.) +
  4. The in operator takes precedence over the or operator, so there is no need for parentheses around (x in a_dictionary) or around (y in a_dictionary). +
  5. On the other hand, you do need parentheses around (x or y) here, for the same reason — in takes precedence over or. (Note: this code is completely different from the previous line. Python interprets x or y first, which results in either x (if x is true in a boolean context) or y. Then it takes that singular value and checks whether it is a key in a_dictionary.)
  6. The in operator takes precedence over the + operator, so this form technically doesn’t need parentheses around (x + y), but 2to3 includes them anyway.
  7. This form definitely needs parentheses around (y in a_dictionary), since the in operator takes precedence over the + operator.