|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Pythonic APIs: the workshop notebook" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "metadata": {}, |
| 13 | + "source": [ |
| 14 | + "## Tutorial overview\n", |
| 15 | + "\n", |
| 16 | + "* Introduction\n", |
| 17 | + "* A simple but full-featured Pythonic class\n", |
| 18 | + " * **Exercise:** custom formatting and alternate constructor\n", |
| 19 | + "* A Pythonic sequence\n", |
| 20 | + " * **Exercise:** implementing sequence behavior\n", |
| 21 | + "* *Coffee break*\n", |
| 22 | + "* A Pythonic sequence (continued)\n", |
| 23 | + " * **Exercise:** custom formatting\n", |
| 24 | + "* Operator overloading\n", |
| 25 | + " * **Exercise:** implement `@` for dot product\n", |
| 26 | + "* Wrap-up\n" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "markdown", |
| 31 | + "metadata": {}, |
| 32 | + "source": [ |
| 33 | + "## Introduction\n", |
| 34 | + "\n", |
| 35 | + "One of the keys to consistent, *Pythonic*, behavior in Python is understanding and leveraging the **Data Model**. The Python Data Model defines standard APIs which enable...\n", |
| 36 | + "\n", |
| 37 | + "### Iteration" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "code", |
| 42 | + "execution_count": 9, |
| 43 | + "metadata": { |
| 44 | + "collapsed": false |
| 45 | + }, |
| 46 | + "outputs": [ |
| 47 | + { |
| 48 | + "name": "stdout", |
| 49 | + "output_type": "stream", |
| 50 | + "text": [ |
| 51 | + "['F', 'l', 'u', 'e', 'n', 't']\n", |
| 52 | + "(10, 20, 30)\n", |
| 53 | + "10\n", |
| 54 | + "20\n", |
| 55 | + "30\n", |
| 56 | + "40\n", |
| 57 | + "50\n" |
| 58 | + ] |
| 59 | + } |
| 60 | + ], |
| 61 | + "source": [ |
| 62 | + "s = 'Fluent'\n", |
| 63 | + "l = [10, 20, 30, 40, 50]\n", |
| 64 | + "\n", |
| 65 | + "print(list(s)) # list constructor iterates over its argument\n", |
| 66 | + "\n", |
| 67 | + "a, b, c, *rest = l # tuple unpacking iterates over right side\n", |
| 68 | + "print((a, b, c))\n", |
| 69 | + "\n", |
| 70 | + "for i in l:\n", |
| 71 | + " print(i)" |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "markdown", |
| 76 | + "metadata": {}, |
| 77 | + "source": [ |
| 78 | + "## A simple but full-featured Pythonic class" |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "markdown", |
| 83 | + "metadata": {}, |
| 84 | + "source": [] |
| 85 | + } |
| 86 | + ], |
| 87 | + "metadata": { |
| 88 | + "kernelspec": { |
| 89 | + "display_name": "Python 3", |
| 90 | + "language": "python", |
| 91 | + "name": "python3" |
| 92 | + }, |
| 93 | + "language_info": { |
| 94 | + "codemirror_mode": { |
| 95 | + "name": "ipython", |
| 96 | + "version": 3 |
| 97 | + }, |
| 98 | + "file_extension": ".py", |
| 99 | + "mimetype": "text/x-python", |
| 100 | + "name": "python", |
| 101 | + "nbconvert_exporter": "python", |
| 102 | + "pygments_lexer": "ipython3", |
| 103 | + "version": "3.5.1" |
| 104 | + } |
| 105 | + }, |
| 106 | + "nbformat": 4, |
| 107 | + "nbformat_minor": 0 |
| 108 | +} |
0 commit comments