The Invent with Python Blog

Mon 07 October 2019

What's New in the 2nd Edition of "Automate the Boring Stuff with Python"

Posted by Al Sweigart in misc   

The second edition of "Automate the Boring Stuff with Python" is almost out! You can preorder it on the No Starch Press website, where buying the print book will get you DRM-free ebooks in PDF, epub, and Kindle formats for free.

The second edition is about 100 pages longer than the first, with new chapters, programming projects, and revised editing. The third party module coverage has been updated to the latest available version (including OpenPyXL).

Like the first edition, the second edition will be released under a Creative Commons license and will be free to read online. The estimated online release is early November on the https://automatetheboringstuff.com.

Some of the new content includes:

  • The Mu editor - The second edition switches from IDLE to Mu, an editor specifically designed for education and beginners. Watch Nicholas Tollervey present Mu at PyCon 2018.
  • Explanation of the call stack - A description of the call stack, which helps the reader understand global and local scopes.
  • The enumerate() function - Using enumarate() in for loops and its advantages over using range().
  • The random.choice() and random.shuffle() functions - These functions in the random module weren't covered before.
  • Identity and the id() function - Added to help explain references and in-place modification.
  • The partition() method - A useful string method similar to join().
  • New chapter: PyInputPlus and input validation - Covers a third party module, PyInputPlus, for input validation and why input validation is important.
  • The pathlib module and Path objects - Explores a new, versatile way to write code that interacts with the file system.
  • OpenPyXL updates - This third party module made several backwards-incompatible changes, confusing some readers who installed the latest version instead of the version in the book. This chapter has been updated to the latest version.
  • New chapter: Working with Google Sheets - A new chapter covering the EZSheets module, allowing your Python scripts to read and update spreadsheets on Google Sheets.
  • New module: EZGmail - The email/SMS chapter now features the EZGmail module, which allows Python scripts to interact with Gmail accounts. Previously this was much more difficult to do via the smtplib and imapclient modules.
  • SMS email gateways - A new section on how to send SMS text messages via the phone carrier's email gateways. Now your Python scripts won't need to use a service such as Twilio to send occasional text messages.
  • MouseInfo app - A small GUI application that is a part of PyAutoGUI which reveals the current coordinates of the mouse. This information is useful for planning out GUI automation tasks.
  • The PyGetWindow module - A new module included in PyAutoGUI that retrieves the coordinates, size, and status of the desktop windows for running programs.
  • The PyMsgBox module - A new module included in PyAutoGUI that provides popup message boxes for your program when it needs to get the attention of the user.
  • Requirements.txt files - Available text files that make it easy to install the exact versions of the modules that the book covers. (See below.)

New projects and programs include:

To avoid installing third-party module versions that the book doesn't cover, I'm making available several requirements.txt files so that pip can easily install the exact versions that the book covers. Download the file for your operating system:

To install, download the file for your operating system. Then open a terminal or command prompt window and run pip install -r automate-<your os>-requirements.txt. If you're using pipenv to create a virtual environment, you'll need to run pipenv install -r automate-<your os>-requirements.txt.

Note that PyAutoGUI requires Pillow, which currently doesn't support Python 3.8 yet.

If you have questions about the second edition or its content, you can post them on the /r/inventwithpython subreddit.