diff --git a/examples/notebooks/Part 1 - Running Code.ipynb b/examples/notebooks/Part 1 - Running Code.ipynb index 12ea0db..9da3129 100644 --- a/examples/notebooks/Part 1 - Running Code.ipynb +++ b/examples/notebooks/Part 1 - Running Code.ipynb @@ -52,7 +52,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "print a" + "print(a)" ], "language": "python", "metadata": {}, @@ -120,7 +120,7 @@ "import sys\n", "from ctypes import CDLL\n", "# This will crash a Linux or Mac system; equivalent calls can be made on Windows\n", - "dll = 'dylib' if sys.platform == 'darwin' else '.so.6'\n", + "dll = 'dylib' if sys.platform == 'darwin' else 'so.6'\n", "libc = CDLL(\"libc.%s\" % dll) \n", "libc.time(-1) # BOOM!!" ], @@ -324,7 +324,7 @@ "input": [ ">>> the_world_is_flat = 1\n", ">>> if the_world_is_flat:\n", - "... print \"Be careful not to fall off!\"" + "... print(\"Be careful not to fall off!\")" ], "language": "python", "metadata": {}, diff --git a/examples/notebooks/Part 2 - Basic Output.ipynb b/examples/notebooks/Part 2 - Basic Output.ipynb index 009c625..fbe134f 100644 --- a/examples/notebooks/Part 2 - Basic Output.ipynb +++ b/examples/notebooks/Part 2 - Basic Output.ipynb @@ -47,7 +47,8 @@ "cell_type": "code", "collapsed": false, "input": [ - "import numpy as np" + "import numpy as np\n", + "import sys" ], "language": "python", "metadata": {}, @@ -58,7 +59,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "numpy.random.rand(10)" + "np.random.rand(10)" ], "language": "python", "metadata": {}, @@ -113,7 +114,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "print \"hi, stdout\"" + "print(\"hi, stdout\")" ], "language": "python", "metadata": {}, @@ -132,7 +133,8 @@ "cell_type": "code", "collapsed": false, "input": [ - "print >> sys.stderr, 'hi, stderr'" + "from __future__ import print_function\n", + "print('hi, stderr', file=sys.stderr)" ], "language": "python", "metadata": {}, @@ -168,7 +170,7 @@ "input": [ "import time, sys\n", "for i in range(8):\n", - " print i,\n", + " print(i)\n", " time.sleep(0.5)" ], "language": "python", @@ -253,7 +255,7 @@ "collapsed": false, "input": [ "for i in range(50):\n", - " print i" + " print(i)" ], "language": "python", "metadata": {}, @@ -329,7 +331,7 @@ "collapsed": false, "input": [ "for i in range(500):\n", - " print 2**i - 1" + " print(2**i - 1)" ], "language": "python", "metadata": {}, @@ -862,6 +864,7 @@ "cell_type": "code", "collapsed": false, "input": [ + "from __future__ import print_function\n", "import sys" ], "language": "python", @@ -881,8 +884,8 @@ "collapsed": false, "input": [ "%%capture\n", - "print 'hi, stdout'\n", - "print >> sys.stderr, 'hi, stderr'" + "print('hi, stdout')\n", + "print('hi, stderr', file=sys.stderr)" ], "language": "python", "metadata": {}, @@ -901,8 +904,8 @@ "collapsed": false, "input": [ "%%capture captured\n", - "print 'hi, stdout'\n", - "print >> sys.stderr, 'hi, stderr'" + "print('hi, stdout')\n", + "print('hi, stderr', file=sys.stderr)" ], "language": "python", "metadata": {}, @@ -1033,13 +1036,13 @@ "input": [ "%%capture wontshutup\n", "\n", - "print \"setting up X\"\n", + "print(\"setting up X\")\n", "x = np.linspace(0,5,1000)\n", - "print \"step 2: constructing y-data\"\n", + "print(\"step 2: constructing y-data\")\n", "y = np.sin(x)\n", - "print \"step 3: display info about y\"\n", + "print(\"step 3: display info about y\")\n", "plt.plot(x,y)\n", - "print \"okay, I'm done now\"" + "print(\"okay, I'm done now\")" ], "language": "python", "metadata": {}, @@ -1088,8 +1091,8 @@ "collapsed": false, "input": [ "%%capture cap --no-stderr\n", - "print 'hi, stdout'\n", - "print >> sys.stderr, \"hello, stderr\"" + "print('hi, stdout')\n", + "print(\"hello, stderr\", file=sys.stderr)" ], "language": "python", "metadata": {}, diff --git a/examples/notebooks/Part 5 - Rich Display System.ipynb b/examples/notebooks/Part 5 - Rich Display System.ipynb index 71c20b3..4f9ab81 100644 --- a/examples/notebooks/Part 5 - Rich Display System.ipynb +++ b/examples/notebooks/Part 5 - Rich Display System.ipynb @@ -452,8 +452,9 @@ "collapsed": false, "input": [ "from IPython.display import HTML\n", + "from base64 import b64encode\n", "video = open(\"animation.m4v\", \"rb\").read()\n", - "video_encoded = video.encode(\"base64\")\n", + "video_encoded = b64encode(video)\n", "video_tag = '