{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Sebastian Raschka](http://sebastianraschka.com) \n", "\n", "last updated 07/02/2016\n", "\n", "- [Open in IPython nbviewer](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/tutorials/key_differences_between_python_2_and_3.ipynb?create=1) \n", "\n", "- [Link to this IPython notebook on Github](https://github.com/rasbt/python_reference/blob/master/tutorials/key_differences_between_python_2_and_3.ipynb) \n", "\n", "- [Link to the GitHub repository python_reference](https://github.com/rasbt/python_reference)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
feature | \n", "optional in | \n", "mandatory in | \n", "effect | \n", "
---|---|---|---|
nested_scopes | \n", "2.1.0b1 | \n", "2.2 | \n", "PEP 227:\n", "Statically Nested Scopes | \n", "
generators | \n", "2.2.0a1 | \n", "2.3 | \n", "PEP 255:\n", "Simple Generators | \n", "
division | \n", "2.2.0a2 | \n", "3.0 | \n", "PEP 238:\n", "Changing the Division Operator | \n", "
absolute_import | \n", "2.5.0a1 | \n", "3.0 | \n", "PEP 328:\n", "Imports: Multi-Line and Absolute/Relative | \n", "
with_statement | \n", "2.5.0a1 | \n", "2.6 | \n", "PEP 343:\n", "The “with” Statement | \n", "
print_function | \n", "2.6.0a2 | \n", "3.0 | \n", "PEP 3105:\n", "Make print a function | \n", "
unicode_literals | \n", "2.6.0a2 | \n", "3.0 | \n", "PEP 3112:\n", "Bytes literals in Python 3000 | \n", "
Python 2.7.6 \n", "[GCC 4.0.1 (Apple Inc. build 5493)] on darwin\n", "Type "help", "copyright", "credits" or "license" for more information.\n", "\n", ">>> my_input = input('enter a number: ')\n", "\n", "enter a number: 123\n", "\n", ">>> type(my_input)\n", "<type 'int'>\n", "\n", ">>> my_input = raw_input('enter a number: ')\n", "\n", "enter a number: 123\n", "\n", ">>> type(my_input)\n", "<type 'str'>\n", "
Python 3.4.1 \n", "[GCC 4.2.1 (Apple Inc. build 5577)] on darwin\n", "Type "help", "copyright", "credits" or "license" for more information.\n", "\n", ">>> my_input = input('enter a number: ')\n", "\n", "enter a number: 123\n", "\n", ">>> type(my_input)\n", "<class 'str'>\n", "