Skip to content

Commit 4e4112c

Browse files
committed
elaborate on readme
1 parent 9c6dbf3 commit 4e4112c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

code-python3/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Updating the code from Python 2 to Python 3
22

3+
After many requests, here's the code from the book updated from Python 2 to Python 3.
4+
I have been telling people that there aren't too many changes required, but it turned
5+
out there were quite a few. Start-to-finish I'd say the porting took me about 4 hours,
6+
and I'm pretty familiar with the code. Here's a fairly comprehensive list of the issues
7+
I ran into.
8+
39
## `print`
410

511
The first and most obvious difference is that in Python 3 `print` takes parentheses.
@@ -15,12 +21,12 @@ had to be replaced with
1521
print("stuff", 1)
1622
```
1723

18-
This is mostly tedious.
24+
This was mostly just tedious. I should have used 2to3.
1925

2026
## tuple unpacking
2127

2228
<a href="https://www.python.org/dev/peps/pep-3113/">PEP-3113</a> eliminates
23-
tuple unpacking in certain places. In particular, that means that code like
29+
tuple unpacking in function parameters. In particular, that means that code like
2430

2531
```
2632
key=lambda (a, b): b
@@ -50,7 +56,7 @@ doesn't work, and needs to be replaced with
5056
list(filter(is_even, my_list))[0]
5157
```
5258

53-
And likewise with `zip`, which in many instances needs to be replaced with `list(zip(...))`.
59+
And likewise with `zip`, which in many instances needs to be replaced with `list(zip(...))`. (In particular, this uglies up my magic unzip trick.)
5460

5561
In the most subtle case this bit me at (in essence):
5662

@@ -68,7 +74,7 @@ data = list(map(clean, data))
6874
```
6975

7076
Similarly, if you have a `dict` then its `.keys()` is lazy, so you have to wrap
71-
it in `list` as well.
77+
it in `list` as well. This is possibly my least favorite change in Python 3.
7278

7379
## binary mode for CSVs
7480

0 commit comments

Comments
 (0)