The Quick Python Book
Last updated
Last updated
The Quick Python Book, Third Edition, is intended for people who already have experience in one or more programming languages and want to learn the basics of Python 3 as quickly and directly as possible. Although some basic concepts are covered, thereâs no attempt to teach fundamental programming skills in this book, and the basic concepts of flow control, OOP, file access, exception handling, and the like are assumed. This book may also be of use to users of earlier versions of Python who want a concise reference for Python 3.
Part 1 introduces Python and explains how to download and install it on your system. It also includes a very general survey of the language, which will be most useful for experienced programmers looking for a high-level view of Python.
Part 2 is the heart of the book. It covers the ingredients necessary for obtaining a working knowledge of Python as a general-purpose programming language. The chapters are designed to allow readers who are beginning to learn Python to work their way through sequentially, picking up knowledge of the key points of the language. These chapters also contain some more-advanced sections, allowing you to return to find in one place all the necessary information about a construct or topic.
Part 3 introduces advanced language features of Pythonâelements of the language that arenât essential to its use but that can certainly be a great help to a serious Python programmer.
Part 4 describes more-advanced or specialized topics that are beyond the strict syntax of the language. You may read these chapters or not, depending on your needs.
A suggested plan if youâre new to Python programming is to start by reading chapter 3 to obtain an overall perspective and then work through the chapters in part 2 that are applicable. Enter in the interactive examples as they are introduced to immediately reinforce the concepts. You can also easily go beyond the examples in the text to answer questions about anything that may be unclear. This has the potential to amplify the speed of your learning and the level of your comprehension. If you arenât familiar with OOP or donât need it for your application, skip most of chapter 15.
Those who are familiar with Python should also start with chapter 3. Itâs a good review and introduces differences between Python 3 and what may be more familiar. Itâs also a reasonable test of whether youâre ready to move on to the advanced chapters in parts 3 and 4 of this book.
Itâs possible that some readers, although new to Python, will have enough experience with other programming languages to be able to pick up the bulk of what they need to get going by reading chapter 3 and by browsing the Python standard library modules listed in chapter 19 and the Python Library Reference in the Python documentation.
Chapter 1 discusses the strengths and weaknesses of Python and shows why Python 3 is a good choice of programming language for many situations.
Chapter 2 covers downloading, installing, and starting up the Python interpreter and IDLE, its integrated development environment.
Chapter 3 is a short overview of the Python language. It provides a basic idea of the philosophy, syntax, semantics, and capabilities of the language.
Chapter 4 starts with the basics of Python. It introduces Python variables, expressions, strings, and numbers. It also introduces Pythonâs block-structured syntax.
Chapters 5, 6, and 7 describe the five powerful built-in Python data types: lists, tuples, sets, strings, and dictionaries.
Chapter 8 introduces Pythonâs control flow syntax and use (loops and if-else statements).
Chapter 9 describes function definition in Python along with its flexible parameter-passing capabilities.
Chapter 10 describes Python modules, which provide an easy mechanism for segmenting the program namespace.
Chapter 11 covers creating standalone Python programs, or scripts, and running them on Windows, macOS, and Linux platforms. The chapter also covers the support available for command-line options, arguments, and I/O redirection.
Chapter 12 describes how to work with and navigate through the files and directories of the filesystem. It shows how to write code thatâs as independent as possible of the actual operating system youâre working on.
Chapter 13 introduces the mechanisms for reading and writing files in Python, including the basic capability to read and write strings (or byte streams), the mechanism available for reading binary records, and the ability to read and write arbitrary Python objects.
Chapter 14 discusses the use of exceptions, the error-handling mechanism used by Python. It doesnât assume that you have any previous knowledge of exceptions, although if youâve previously used them in C++ or Java, youâll find them familiar.
Chapter 15 introduces Pythonâs support for writing object-oriented programs.
Chapter 16 discusses the regular-expression capabilities available for Python.
Chapter 17 introduces more-advanced OOP techniques, including the use of Pythonâs special method-attributes mechanism, metaclasses, and abstract base classes.
Chapter 18 introduces the package concept in Python for structuring the code of large projects.
Chapter 19 is a brief survey of the standard library. It also includes a discussion of where to find other modules and how to install them.
Chapter 20 dives deeper into manipulating files in Python.
Chapter 21 covers strategies for reading, cleaning, and writing various types of data files.
Chapter 22 surveys the process, issues, and tools involved in fetching data over the network.
Chapter 23 discusses how Python accesses relational and NoSQL databases.
Chapter 24 is a brief introduction to using Python, Jupyter notebook, and pandas to explore data sets.
The case study walks you through using Python to fetch data, clean it, and then graph it. The project combines several features of the language discussed in the chapters, and it gives you a chance to a see a project worked through from beginning to end.
Appendix A contains a guide to obtaining and accessing Pythonâs full documentation, the Pythonic style guide, PEP 8, and âThe Zen of Python,â a slightly wry summary of the philosophy behind Python.
Appendix B has the answers to most of the exercises. In a few cases, the exercises ask you to experiment on your own. I donât attempt to provide answers for those exercises.
The code samples in this book, and their output, appear in a fixed-width font and are often accompanied by annotations. The code samples are deliberately kept as simple as possible, because they arenât intended to be reusable parts that can be plugged into your code. Instead, the code samples are stripped down so that you can focus on the principle being illustrated.
In keeping with the idea of simplicity, the code examples are presented as interactive shell sessions where possible; you should enter and experiment with these samples as much as you can. In interactive code samples, the commands that need to be entered are on lines that begin with the >>> prompt, and the visible results of that code (if any) are on the line below.
In some cases a longer code sample is needed, and these cases are identified in the text as file listings. You should save these listings as files with names matching those used in the text and run them as standalone scripts.
Starting in chapter 4, this book provides three kinds of exercises. The Quick Check exercises are very brief questions that encourage you to pause and make sure youâre clear on an idea just presented. The Try This exercises are a bit more demanding and usually suggest that you try your hand at some Python code. At the end of many chapters is a Lab, which gives you a chance to put the concepts of the current and previous chapters together for a complete script.
Answers to most of the exercises are available in appendix B and are also included in a separate directory along with the bookâs source code. Keep in mind that the answers are not meant to be the only answers for the coding problems; there may be several other approaches. The best way to judge your answers is to understand what the suggested answer does and then decide whether your answer achieves the same end.
The source code for the samples in this book is available from the publisherâs website at www.manning.com/books/the-quick-python-book-third-edition.
The samples and code in this book have been written with Windows (Windows 7 through 10), macOS, and Linux in mind. Because Python is a cross-platform language, the samples and code should work on other platforms for the most part, except for platform-specific issues, such as the handling of files, paths, and GUIs.
This book is based on Python 3.6, and all examples should work on any subsequent version of Python 3. (Most have been tested with a prerelease version of Python 3.7.) With a few exceptions, the examples also work on Python 3.5, but I strongly recommend using 3.6; there are no advantages to using the earlier version, and 3.6 has several subtle improvements. Note that Python 3 is required and that an earlier version of Python will not work with the code in this book.
The purchase of The Quick Python Book, Third Edition, includes free access to a private web forum run by Manning Publications, where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://forums.manning.com/forums/the-quick-python-book-third-edition. You can also learn more about Manningâs forums and the rules of conduct at https://forums.manning.com/forums/about.
Manningâs commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. Itâs not a commitment to any specific amount of participation on the part of the author, whose contribution to the bookâs forum remains voluntary (and unpaid). We suggest that you try asking her some challenging questions, lest her interest stray!
The forum and the archives of previous discussions will be accessible from the publisherâs website as long as the book is in print.
NAOMI CEDER, the author of this third edition, has been programming in various languages for nearly 30 years and has been a Linux system administrator, programming teacher, developer, and system architect. She started using Python in 2001, and since then has taught Python to users at all levels, from 12-year-olds to professionals. She gives talks on Python and the benefits of an inclusive community to whomever will listen. Naomi currently leads a development team for Dick Blick Art Materials and is the chair of the Python Software Foundation.
Reference : https://livebook.manning.com/book/the-quick-python-book-third-edition/about-this-book/