Skip to content

Commit 0fa487f

Browse files
committed
started workshop notebook
1 parent 5d5a83c commit 0fa487f

File tree

2 files changed

+118
-10
lines changed

2 files changed

+118
-10
lines changed

pythonic-api-notebook.ipynb

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
}

syllabus.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,25 @@ Estimated time per topic in minutes (total: 180', including 15' coffee break)
4040
* (3') Tutorial Overview
4141
* A simple but full-featured Pythonic class
4242
* (4') Object representation
43-
* (10') Exercise: Implement an Alternative Constructor
4443
* (7') Formatted Displays
45-
* (9') A Hashable Vector2d
46-
* (4') "Private" and “Protected” Attributes in Python
47-
* (5') The __slots__ Class Attribute: Use and Caveats
44+
* (10') **Exercise:** Polar Format and Alternative Constructor
45+
* (9') A Hashable ``Vector2d``
46+
* (4') “Private” and “Protected” Attributes in Python
47+
* (5') The ``__slots__`` Class Attribute: Use and Caveats
4848
* (9') Overriding Class Attributes
4949
* A Pythonic Sequence
5050
* (7') The Sequence Interface
51-
* (15') Exercise: Implementing Sequence Behavior
51+
* (15') **Exercise:** Implementing Sequence Behavior
5252
* (15') -------------- Coffee Break --------------
5353
* A Pythonic Sequence (continued)
54-
* (14') Slice-Aware __getitem__
54+
* (14') Slice-Aware ``__getitem__``
5555
* (7') Dynamic Attribute Access
56-
* (10') Hashing and a Faster ==
56+
* (10') Hashing and a Faster ``==``
5757
* (12') Exercise: Implement Formatting Support
5858
* Operator Overloading Done Right
5959
* (5') Unary Operators
60-
* (10') Overloading + for Vector Addition
61-
* (7') Overloading * for Scalar Multiplication
62-
* (10') Exercise: Implement @ for Dot Product
60+
* (7') Overloading ``*`` for Scalar Multiplication
61+
* (10') Overloading ``+`` for Vector Addition
62+
* (10') **Exercise:** Implement ``@`` for Dot Product
6363
* (7') Rich Comparison Operators
6464
* (7') Augmented Assignment Operators

0 commit comments

Comments
 (0)