Skip to content

Commit bec6b4f

Browse files
committed
Update cheatsheet notebook
1 parent 42d9144 commit bec6b4f

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

docs/notebooks/Writing Python 2-3 compatible code.ipynb

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:c37888c8f9a1f8ba6d3693b55f121f2581ba744bc5feb6b9153a419891328945"
4+
"signature": "sha256:5214500bd0fe36eb284cf7f699558f65c1ec6897953be31caaed9ee69aea1718"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -121,7 +121,8 @@
121121
"collapsed": false,
122122
"input": [
123123
"# Python 2 and 3:\n",
124-
"from __future__ import print_function\n",
124+
"from __future__ import print_function # (at top of module)\n",
125+
"\n",
125126
"print('Hello', 'Guido')"
126127
],
127128
"language": "python",
@@ -144,7 +145,7 @@
144145
"collapsed": false,
145146
"input": [
146147
"# Python 2 and 3:\n",
147-
"from __future__ import print_function # (at top of module)\n",
148+
"from __future__ import print_function\n",
148149
"\n",
149150
"print('Hello', file=sys.stderr)"
150151
],
@@ -168,7 +169,7 @@
168169
"collapsed": false,
169170
"input": [
170171
"# Python 2 and 3:\n",
171-
"from __future__ import print_function # (at top of module)\n",
172+
"from __future__ import print_function\n",
172173
"\n",
173174
"print('Hello', end='')"
174175
],
@@ -206,35 +207,6 @@
206207
"metadata": {},
207208
"outputs": []
208209
},
209-
{
210-
"cell_type": "markdown",
211-
"metadata": {},
212-
"source": [
213-
"Raising bare string exceptions:"
214-
]
215-
},
216-
{
217-
"cell_type": "code",
218-
"collapsed": false,
219-
"input": [
220-
"# Python 2 only:\n",
221-
"raise \"dodgy value\""
222-
],
223-
"language": "python",
224-
"metadata": {},
225-
"outputs": []
226-
},
227-
{
228-
"cell_type": "code",
229-
"collapsed": false,
230-
"input": [
231-
"# Python 2 and 3:\n",
232-
"raise Exception(\"dodgy value\")"
233-
],
234-
"language": "python",
235-
"metadata": {},
236-
"outputs": []
237-
},
238210
{
239211
"cell_type": "markdown",
240212
"metadata": {},
@@ -667,7 +639,7 @@
667639
"collapsed": false,
668640
"input": [
669641
"# Python 3 only:\n",
670-
"class Form(metaclass=BaseForm):\n",
642+
"class Form(BaseForm, metaclass=FormType):\n",
671643
" pass"
672644
],
673645
"language": "python",

0 commit comments

Comments
 (0)