From 642c94a348ab7a5b841f05ba12d67dfbe460d2e9 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Thu, 16 Jul 2009 08:06:12 -0400 Subject: [PATCH] clarified dictionary.has_key(x or y) --- porting-code-to-python-3-with-2to3.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index 5290ddf..cbc611e 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -159,7 +159,7 @@ td pre{padding:0;border:0}
  1. The simplest form.
  2. The or operator takes precedence over the in operator, so there is no need for parentheses here. -
  3. On the other hand, you do need parentheses here, for the same reason — or takes precedence over in. +
  4. On the other hand, you do need parentheses 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.)
  5. The in operator takes precedence over the + operator, so this form technically doesn’t need parentheses, but 2to3 includes them anyway.
  6. This form definitely needs parentheses, since the in operator takes precedence over the + operator.