Preface to the Third Edition
The response to the first and second editions of Python Crash Course has been overwhelmingly positive. More than one million copies are in print, including translations in over 10 languages. I’ve received letters and emails from readers as young as 10, as well as from retirees who want to learn to program in their free time. Python Crash Course is being used in middle schools and high schools, and also in college classes. Students who are assigned more advanced textbooks are using Python Crash Course as a companion text for their classes and finding it a worthwhile supplement. People are using it to enhance their skills on the job, change careers, and start working on their own side projects. In short, people are using the book for the full range of purposes I had hoped they would, and much more.
The opportunity to write a third edition of Python Crash Course has been thoroughly enjoyable. Although Python is a mature language, it continues to evolve as every language does. My main goal in revising the book is to keep it a well-curated introductory Python course. By reading this book, you’ll learn everything you need to start working on your own projects, and you’ll build a solid foundation for all of your future learning as well. I’ve updated some sections to reflect newer, simpler ways of doing things in Python. I’ve also clarified some sections where certain details of the language were not presented as accurately as they could have been. All the projects have been completely updated using popular, well-maintained libraries that you can confidently use to build your own projects.
The following is a summary of specific changes that have been made in the third edition:
- Chapter 1 now features the text editor VS Code, which is popular among beginner and professional programmers and works well on all operating systems.
- Chapter 2 includes the new methods
removeprefix() and removesuffix(), which are helpful when working with files and URLs. This chapter also features Python’s newly improved error messages, which provide much more specific information to help you troubleshoot your code when something goes wrong.
- Chapter 10 uses the
pathlib module for working with files. This is a much simpler approach to reading from and writing to files.
- Chapter 11 uses
pytest to write automated tests for the code you write. The pytest library has become the industry standard tool for writing tests in Python. It’s friendly enough to use for your first tests, and if you pursue a career as a Python programmer, you’ll use it in professional settings as well.
- The Alien Invasion project in Chapters 12−14 includes a setting to control the frame rate, which makes the game run more consistently across different operating systems. A simpler approach is used to build the fleet of aliens, and the overall organization of the project has been cleaned up as well.
- The data visualization projects in Chapters 15–17 use the most recent features of Matplotlib and Plotly. The Matplotlib visualizations feature updated style settings. The random walk project has a small improvement that increases the accuracy of the plots, which means you’ll see a wider variety of patterns emerge each time you generate a new walk. All the projects featuring Plotly now use the Plotly Express module, which lets you generate your initial visualizations with just a few lines of code. You can easily explore a variety of visualizations before committing to one kind of plot, and then focus on refining individual elements of that plot.
- The Learning Log project in Chapters 18−20 is built using the latest version of Django and styled using the latest version of Bootstrap. Some parts of the project have been renamed to make it easier to follow the overall organization of the project. The project is now deployed to Platform.sh, a modern hosting service for Django projects. The deployment process is controlled by YAML configuration files, which give you a great deal of control over how your project is deployed. This approach is consistent with how professional programmers deploy modern Django projects.
- Appendix A has been fully updated to recommend current best practices for installing Python on all major operating systems. Appendix B includes detailed instructions for setting up VS Code, and brief descriptions of most of the major text editors and IDEs in current use. Appendix C directs readers to several of the most popular online resources for getting help. Appendix D continues to offer a mini crash course in using Git for version control. Appendix E is brand new for the third edition. Even with a good set of instructions for deploying the apps you create, there are many things that can go wrong. This appendix offers a detailed troubleshooting guide that you can use when the deployment process doesn’t work on the first try.
- The index has been thoroughly updated to allow you to use Python Crash Course as a reference for all of your future Python projects.
Thank you for reading Python Crash Course! If you have any feedback or questions, please feel free to get in touch; I am @ehmatthes on Twitter.