Automate the Boring Stuff

by Erik Adams

At my firm we have online learning sessions that happen almost every Wednesday between 11:00 AM and 12:30 PM. Before the training session, I send an email to attorneys in 3 different time zones to remind them of the event and provide the technical details of how to participate – who will be hosting, the phone number to call, and a link to join. For various policy reasons, I have to send multiple versions of this message. One of the small changes I make to the message is the subject line, which gets customized to the time zone of the recipient: attorneys in California see “Online learning this morning from 11:00 AM to 12:30 PM”, while attorneys in New York see “Online learning this afternoon from 2:00 to 3:30 PM”. All told, I have to create 11 versions of this message, and it takes me about 10 minutes, much of which is spent waiting for my computer to actually send the messages. It would be nice if I could just push a button and have all 11 versions generated automatically and emailed.

This is a task for automation. I do a lot of programming when I’m not providing research, instruction, or patron services, so it isn’t a scary proposition. But I know from my conversations with other librarians that programming is not a common skill. There are a variety of reasons for this, but I think there are two big hurdles: programming languages can be difficult to read and understand, and most introductions to programming start with inane examples that don’t have any bearing on the real world. I have an answer to both of these issues: learn to program in Python, and read the book Automate the Boring Stuff, which is available for free on the Internet.

Originally conceived by Guido van Rossum, Python is a programming language designed so that programs are easy to create and maintain. As the documentation states, “One of Guido’s key insights is that code is read much more often than it is written.” Or, as The Zen of Python notes, “Readability counts.” Where many program languages are littered with semi colons, curly braces, and odd combinations of punctuation, Python uses empty space and plain English. Instead of

foo == null ? result1 : result2;

In Python you have

result1 if foo is None else result2

(Perhaps this is why Python never shows up in television or movies when a clever hacker is breaking into a complicated system. One of my favorite tumblrs is Source Code in TV and Films, which catalogs where computer programs actually come from. Most of the time it appears to be Javascript, a language with lots of semi colons and curly braces.)

The best way to learn a programming language is to use it. I don’t think anyone working in a library is interested in generating a Fibonacci series, or creating a version of the game Battleship, or translating English into Pig Latin. These are typical introductory tasks in programming classes, but they are far removed from anything practical. In contrast, Automate the Boring Stuff focuses on getting the reader up to speed on the basics of Python and quickly doing useful things. The book focuses on useful things as a way to introduce the reader to more advanced concepts. There are chapters devoted to working with PDF and Word documents, manipulating Excel spreadsheets, and even one on sending email. Just what I need to automate my weekly 11 email messages.

At my firm we try to automate as much as possible. If you find yourself doing repetitive task, ask yourself if that task can’t be automated. Some things can’t, but once you start you’ll find that more and more things can be. Being able to automate those tasks yourself will guarantee you never have to wait for an IT department to finally let a developer work on your projects.

This entry was posted in Issues in Law Librarianship, Legal Technology and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s