Supporting Python 3: An in-depth guide

About this book

This book is an open book whose source is available on GitHub[5] so that anyone can contribute to the book. The author and editor is Lennart Regebro, and future contributors will be listed here.

This book is written in reStructuredText[1], typeset with Sphinx[2] and LaTeX[3] and printed on CreateSpace[4]. The typefaces used are TeX Gyre Schola for the main text, DejaVu Sans Mono for the code and Flux Bold for headings.

The cover photo is taken by Emmanuel “Tambako” Keller, http://www.flickr.com/photos/tambako/

There is a list of errata on the books web page, http://python3porting.com/.

Lennart Regebro would like to thank the following persons for helping making this book much better:

Andreas Braukmann, Nicholas Coghlan, Paul Everitt, Cris Ewing, Luca Fabbri, Russell Ferriday, Patrick Gerken, Janko Hauser, Domen Kožar, Baptiste Mispelon, Alexander Pilz, Johannes Raggam, Luciano Ramalho, Matt Russell, Christian Theune, Sébastien Verbois and Ian Watt for generously funding the crowd funding campaign to make this book a community effort.

Brett Cannon for writing the foreword.

Martin von Löwis for indispensable feedback with his technical review of the book, as well as helping a lot on early efforts to support Python 3, like Distribute and zope.interface.

Godefroid Chapelle, Jasper Spaans and Wyn Williams for reviewing the book for content, grammar and errors.

Brandon Craig Rhodes for editing the first chapters of this book when the idea was that it would be a series of articles in Python Magazine.

See also CONTRIBUTORS.txt for everyone who has made bugfixes, spelling corrections and other additions to this book.

A note on terminology

The process of switching to Python 3 is most often called “porting”. The first two editions of this book was also called “Porting to Python 3”. However, this gave the false impression that this was a lot of work, and that Python 3 was “a different language” than Python 2. Although moving to Python 3 can be hard work, for the most time it is not, and as Python 2.5 and Python 3.2 are rapidly falling out of use, it gets even easier.

For that reason, I changed the name of the book to “Supporting Python 3” as this better reflects the effort. It’s not porting, the vast majority of your code will work with no changes, or changes that can be done automatically with 2to3.

I have tried to avoid using the word “porting” in the text as a part of this.

Footnotes

[1]http://docutils.sourceforge.net/rst.html
[2]http://sphinx.pocoo.org/
[3]http://www.latex-project.org/
[4]https://www.createspace.com/
[5]https://github.com/regebro/supporting-python-3