© Joannah Nanjekye 2017
Joannah NanjekyePython 2 and 3 Compatibilityhttps://doi.org/10.1007/978-1-4842-2955-2_1

1. Printing and Backtick repr

Joannah Nanjekye
(1)
Kampala, Uganda
 
Printing is the most well-known difference between Python 2 and Python 3. The print statement in Python 2 does not require parentheses; it is a function in Python 3. There is also a difference in the backtick repr. This chapter discusses the polarities of these features between the Python versions and the techniques to achieve their compatibility.

Print

As discussed in this book’s introduction, the print statement in Python 2 became a function in Python 3, which means that we have to wrap the content that we want to print within parentheses. Before we start converting some ...

Get Python 2 and 3 Compatibility: With Six and Python-Future Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.