Python 3 created a clear distinction between bytes and text, as opposed to Python 2 that uses the str type for both text and bytes. Python 2’s idea of the str type led to a scenario where code worked for either type of data, or sometimes none. On the other hand, Python 3 requires that you care about when you are using text (as compared to binary data). This chapter describes how to absorb these differences in a single code base that can run in both Python versions. First, let’s look at these differences.
Text and Binary Data
In Python 2, any string that appears in normal quotes are ...