Automating your workflow with Python

10532818815 0c0284b6d0 z
Credit: Tambako The Jaguar / Flickr

If you want to become more productive, 'Automate the Boring Stuff with Python' is the place to start


[See the end of this article for an update.]

"Don’t spend your time doing work a well-trained monkey could do. Even if you’ve never written a line of code, you can make your computer do the grunt work." - Al Sweigart, author of  Automate the Boring Stuff with Python

Sweigart's right, most computer users do far more drudge work than they need to simply because they don’t know how to automate what they do. 

The trouble is that most automation tools aren’t that easy to use. Batch files, for example, are okay for really simple tasks but it takes serious effort and skill to create batch files that do anything even slightly complicated without bombing. What about using programming languages? Does learning a programming language make the task easier? That’s debatable. For most people, I’d say not. Indeed, I’d go further and say that given most users’ general lack of understanding of computers, providing Joe Fatfingers with any kind of automation or programming tools is akin to giving a teenager the keys to a Ferrari … no good can come of it and disaster will be, literally, just around the corner.

On the other hand for more skilled users, teaching them how to program and giving them effective tools has, potentially, enormous value. But what tools to give them?

I have become a big fan of the Python language due to its elegance and power and that’s why Sweigart argues it's a good vehicle for teaching programming and, specifically, a great way to automate the boring stuff.

automate cover front new No Strach Press

Part I of Automate the Boring Stuff with Python is pretty much a standard introduction to Python covering the interactive shell, data types, string operations, flow control, function, lists and list operations, and so on. Even if you think you have a pretty good grasp of Python, unless you’re a seasoned Python programmer, you’ll probably get a lot out reviewing the fundamentals a la Sweigart; his writing is clear and considerably easier to follow than the more geeky Python tomes. Each chapter also includes a practice questions section so you can check your understanding.

Part I ends with two projects, the first to create a simple (i.e. insecure) password locker which demonstrates stuffing the clipboard and the second, a program to add bullets to wiki markup stored in the clipboard.

Part II focuses on automating tasks and begins with a primer on our old friend, regular expressions which leads to a project to extract phone numbers and email addresses from text stored in the clipboard. After that come projects that demonstrate file operations; creating archives using ZIP compression; web scraping and controlling browsers; manipulating Excel spreadsheets, PDF files, Word, CSV, and JSON documents; keeping time; scheduling tasks; launching programs; sending email and text messages; manipulating images; and controlling the keyboard and mouse.

Some of the projects will be immediately useful while others will be more like stepping stones to building customized programs specific to your own workflow. What this book does really well is to give you the foundational techniques for doing useful automation. It also provides clear examples of Python code that you might not find elsewhere. For example, just before reading the book I had been wrestling with the BeautifulSoup library for extracting data from HTML and XML content. Automate the Boring Stuff with Python has a project that uses this library and the explanation of how to use BeautifulSoup solved my problem (or, more accurately, solved my misunderstanding).

So, do you need Automate the Boring Stuff with Python? Yes, if you want to enhance your workflow by using automation, this is an excellent place to start. Automate the Boring Stuff with Python is from No Starch Press priced at $29.95 for a print version with a free PDF version, or $23.95 for the ebook version (PDF, Mobi, and ePub). Highly recommended.

UPDATE: Sweigart has created a special discounted offer for Network World readers to take his online "Automate the Boring Stuff with Python Programming" course via Udemy.

Must read: Hidden Cause of Slow Internet and how to fix it
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies