Skip to content

Commit ebefae2

Browse files
committed
Fix doc bug (cheat sheet: iteritems import) (issue #120)
1 parent 8dce1a6 commit ebefae2

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

docs/compatible_idioms.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,14 @@ Iterable dict items:
533533
.. code:: python
534534
535535
# Python 2 and 3: option 2
536-
from builtins import iteritems
536+
from future.utils import viewitems
537+
538+
for (key, value) in viewitems(heights): # also behaves like a set
539+
...
540+
.. code:: python
541+
542+
# Python 2 and 3: option 3
543+
from future.utils import iteritems
537544
# or
538545
from six import iteritems
539546

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:7fe04ffd8c478c4d6b7653aab35c47f3117c50ae383326dfeca599d53603d031"
4+
"signature": "sha256:fa152cbedcb4d5d5c255d3456863fe07938d6196acf812a42c7c9ea3869c9f1b"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -1147,7 +1147,21 @@
11471147
"collapsed": false,
11481148
"input": [
11491149
"# Python 2 and 3: option 2\n",
1150-
"from builtins import iteritems\n",
1150+
"from future.utils import viewitems\n",
1151+
"\n",
1152+
"for (key, value) in viewitems(heights): # also behaves like a set\n",
1153+
" ..."
1154+
],
1155+
"language": "python",
1156+
"metadata": {},
1157+
"outputs": []
1158+
},
1159+
{
1160+
"cell_type": "code",
1161+
"collapsed": false,
1162+
"input": [
1163+
"# Python 2 and 3: option 3\n",
1164+
"from future.utils import iteritems\n",
11511165
"# or\n",
11521166
"from six import iteritems\n",
11531167
"\n",

0 commit comments

Comments
 (0)