diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index 7a7d8a5..7d64e62 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -157,8 +157,8 @@ td pre{padding:0;border:0}
  • The simplest form.
  • The or operator takes precedence over the in operator, so there is no need for parentheses here.
  • On the other hand, you do need parentheses here, for the same reason — or takes precedence over in. -
  • The in operator takes precedence over the + operator, so this form needs parentheses too. -
  • Again with the parentheses, for the same reason. +
  • The in operator takes precedence over the + operator, so this form technically doesn’t need parentheses, but 2to3 includes them anyway. +
  • This form definitely needs parentheses, since the in operator takes precedence over the + operator.

    Dictionary methods that return lists

    In Python 2, many dictionary methods returned lists. The most frequently used methods were keys(), items(), and values(). In Python 3, all of these methods return dynamic views. In some contexts, this is not a problem. If the method’s return value is immediately passed to another function that iterates through the entire sequence, it makes no difference whether the actual type is a list or a view. In other contexts, it matters a great deal. If you were expecting a complete list with individually addressable elements, your code will choke, because views do not support indexing. diff --git a/your-first-python-program.html b/your-first-python-program.html index 53f56f5..2aa0582 100644 --- a/your-first-python-program.html +++ b/your-first-python-program.html @@ -150,12 +150,6 @@ SyntaxError: non-keyword arg after keyword arg

    Many Python IDEs use the docstring to provide context-sensitive documentation, so that when you type a function name, its docstring appears as a tooltip. This can be incredibly helpful, but it’s only as good as the docstrings you write.

    -

    Everything Is An Object

    In case you missed it, I just said that Python functions have attributes, and that those attributes are available at runtime. A function, like everything else in Python, is an object.

    Run the interactive Python shell and follow along: