diff --git a/tutorials/key_differences_between_python_2_and_3.ipynb b/tutorials/key_differences_between_python_2_and_3.ipynb index 22a8f86..ac07efa 100644 --- a/tutorials/key_differences_between_python_2_and_3.ipynb +++ b/tutorials/key_differences_between_python_2_and_3.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:2d8d614150aba437b28f7fe22d2e6a05b76ddb1a447d645c7d5085ab0c286c44" + "signature": "sha256:3442b8345ce99d8d379e475a753f23abf3392c6d4a6fdf185cf061e73e09b9e1" }, "nbformat": 3, "nbformat_minor": 0, @@ -151,13 +151,13 @@ "generators\n", "2.2.0a1\n", "2.3\n", - "PEP 255:\n", + "PEP 255:\n", "Simple Generators\n", "\n", "division\n", "2.2.0a2\n", "3.0\n", - "<PEP 238:\n", + "PEP 238:\n", "Changing the Division Operator\n", "\n", "absolute_import\n", @@ -198,7 +198,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 3 + "prompt_number": 1 }, { "cell_type": "markdown", @@ -227,10 +227,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Very trivial, and the change in the print-syntax is probably the most widely known change, but still it is worth mentioning: Python 2's print function doesn't require the parantheses for invoking the print function (it wouldn't choke on them). \n", - "In contrast, Python 3 would raise a `SyntaxError` if we called the print function the Python 2-way without the parentheses. \n", + "Very trivial, and the change in the print-syntax is probably the most widely known change, but still it is worth mentioning: Python 2's print statement has been replaced by the `print()` function, meaning that we have to wrap the object that we want to print in parantheses. \n", "\n", - "I think this change in Python 3 makes sense in terms of consistency, since it is the common way in Python to invoke function calls with its parentheses." + "Python 2 doesn't have a problem with additional parantheses, but in contrast, Python 3 would raise a `SyntaxError` if we called the print function the Python 2-way without the parentheses. \n" ] }, { @@ -324,6 +323,38 @@ ], "prompt_number": 3 }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Note:**\n", + "\n", + "Printing \"Hello, World\" above via Python 2 looked quite \"normal\". However, if we have multiple objects inside the parantheses, we will create a tuple, since `print` is a \"statement\" in Python 2, not a function call." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print 'Python', python_version()\n", + "print('a', 'b')\n", + "print 'a', 'b'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Python 2.7.6\n", + "('a', 'b')\n", + "a b\n" + ] + } + ], + "prompt_number": 4 + }, { "cell_type": "markdown", "metadata": {},