Python 3 success

Wrote my first Python 3 program. I was trying to get a Python 2 program to read a CSV file and write it to sqlite3. Difficulty level: Unicode. After reading all the nonsense about how the Python 2 CSV module doesn’t really do Unicode but hey it’s OK it’s bytes and here’s a wrapper you can paste in your code, I got fed up and installed Python 3.

So far so good. My 20 lines of code ran exactly fine in Python 3 first try, with the benefit that Unicode didn’t suck. The only thing that really tripped me up doing things is that print is a function, not a statement, and that’s a very good change. I even tried out the new string formatting system, here’s an idiom for using locals() for quick debug printing:

print ("{date} {asin} {title}".format(**locals()))

My one concern is Python 3 co-existing with Python 2. The Homebrew install seems to name things “python3” and “pip3” and the like, so all is well? But the recommended “pip3 install –upgrade distribute” didn’t work; that fetched some version of distribute that’s not Python 3 compatible.

Now that I’m over this hump I hope to use Python 3 for more things.