I strived to follow PEP 8 standards (for the most part) and write the code in such a way so that it runs equivalently in both Python Version 2 and Python Version 3. You can now enjoy reading the code samples in your language of choice.
That being said, I still want to emphasize that the concepts in this book apply to virtually all coding languages, and I expect that some people not as familiar with Python will be reading this book. Because of this, sometimes I have avoided certain Python idioms where I thought that this would utterly confuse people coming from other languages. It’s a tricky balance to keep the code Pythonic while also being welcoming to non-Python coders, but I hope that I’ve maintained an equilibrium that satisfies most readers.
Virtually all the code in this book can be downloaded online from the book’s web page. This code repository contains automated tests too! I encourage you to check that out since the tests don’t appear in the actual book.
You’ll find some longer code snippets under the headings that read “Code Implementation.” I certainly encourage you to study these code samples, but you don’t necessarily have to understand every last line to proceed to the next section of the book. If these long pieces of code are bogging you down, just skim (or skip) them for now.
Finally, it’s important to note that the code in this book is not “production ready.” My greatest focus has been to clarify the concept at hand, and while I did also try to make the code generally complete, I have not accounted for every edge case. There’s certainly room for you to optimize the code further—so feel free to go crazy with that.