Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "IP addresses have been assigned to your computer by running the ip addr
or ipconfig /all
command on Windows."
A block of code is set as follows:
import sys, urllib.request try: rfc_number = int(sys.argv[1]) except (IndexError, ValueError): print('Must supply an RFC number as first argument') sys.exit(2) template = 'http://www.ietf.org/rfc/rfc{}.txt' url = template.format(rfc_number) rfc_raw = urllib.request.urlopen(url).read() rfc = rfc_raw.decode() print(rfc)
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are highlighted:
<body>
...
<div id="content">
<h1>Debian “jessie” Release Information</h1>
<p>Debian 8.0 was
released October 18th, 2014.
The release included many major
changes, described in
...
Any command-line input or output is written as follows:
$ python RFC_downloader.py 2324 | less
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "We can see there's a list of interfaces below the Start button."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
We follow PEP 8 as closely as we can, but we also follow the principle that practicality beats purity, and do deviate in a few areas. Imports are often performed on a single line to save space, and we may not strictly adhere to wrapping conventions do to the nature of printed media; we aim for "readability counts".
We have also chosen to focus on the procedural programming style rather than use object-oriented examples. The reason for this is that it is generally easier for someone familiar with object oriented programming to rework procedural examples into an object oriented format than it is for someone unfamiliar with OOP to do the reverse.