To get the most out of this book
Depending on your level of experience you should start reading from the beginning, or gloss over the chapters to skip to sections that are interesting for you. This book is suitable for intermediate to expert level Python programmers, but not all sections will be equally useful for everyone.
As an example, the first two chapters are about setting up your environment and Python interpreter and seem like chapters you can skip entirely as an advanced or expert Python programmer, but I would advise against fully skipping them, as a few useful utilities and libraries are covered which you might not be familiar with.
The chapters of this book do build on each other to a certain degree, but there is no strict reading order and you can easily cherry-pick the parts you wish to read. If there is a reference to an earlier chapter, it is clearly indicated.
The most up-to-date version of the code samples can always be found at https://github.com/mastering-python/code_2.
The code in this repository is automatically tested and, if you have any suggestions, pull requests are always welcome.
Most chapters of this book also include exercises at the end that will allow you to test what you have learned. Since there are always multiple solutions to problems, you, and every other reader of this book, can submit and compare your solutions on GitHub: https://github.com/mastering-python/exercises
You are encouraged to create a pull request with your solution to the problems. And you can learn from others here as well, of course.
Download the example code files
The code bundle for the book is hosted on GitHub at https://github.com/mastering-python/code_2 and pull requests with improvements are welcome. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781800207721_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
While this book largely adheres to the PEP8 styling conventions, there are a few concessions made due to the space limitations of a book format. Simply put, code samples that span multiple pages are hard to read, so some parts use less whitespace than you would usually expect. The full version of the code is available on GitHub and is automatically tested to be PEP8-compliant.
CodeInText
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “The itertools.chain()
generator is one of the simplest yet one of the most useful generators in the Python library.”
A block of code is set as follows:
from . import base
class A(base.Plugin):
pass
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
:show-inheritance:
:private-members:
:special-members:
:inherited-members:
Any command-line input or output is written as follows:
$ pip3 install -U mypy
Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes. For example: “Sometimes interactive interpreters are referred to as REPL. This stands for Read-Eval-Print-Loop.”
Warnings or important notes appear like this.
Tips and tricks appear like this.