Automate the Boring Stuff with Python
automatetheboringstuff.com
automatetheboringstuff.com
edit: I had pitched this topic for a conference, though I'm mostly expecting it to be rejected for, well, being too mundane :) http://srccon.org/sessions/proposals/#proposal-106215
> Programming creates so many technical and creative inventions that it's natural for aspiring programmers to dream of big projects in the cloud. But this ambition ignores the actual goal of programming, which is almost completely about making machines do mundane work. And it is counterproductive to learning how to program, which requires consistent practice as in every other form of literacy and art. So this session will be about mundane programming. Programming not to be the next Zuckerberg, or to get a better job 3 months from now, but to make today or just the next ten minutes more enjoyable. Instead of focusing specifically on how to code, we'll expand upon the reasons of why we code (though seeing is often believing when it comes to code, so feel free to bring both ideas and Gists). And we'll trim the personal prerequisites of programming, which don't include being an entrepreneur, having a profitable idea, building a website, contributing to open source, or changing the world or your career. Programming can be learned, and done, with a willingness to learn and a wide variety of small problems to practice upon.
Or maybe it's not that scary for people to learn programming if you don't mention the word "programming"? It doesn't seem to be the intention here, the first part's title is "The Basics of Python Programming". But it seems to be a good strategy to appeal with the title first than in the TOC face the reader with the truth: what you are going to read about is programming.
I know, I speculate too much. But I really like this title. I can imagine a businessman in a bookstore at the "computer" section looking for Excel or Word books looking into this book, while filtering out all "programming" books in his vision.
“You’ve just done in two hours what it takes the three of us two days to do.” My college roommate was working at a retail electronics store in the early 2000s. Occasionally, the store would receive a spreadsheet of thousands of product prices from its competitor. A team of three employees would print the spreadsheet onto a thick stack of paper and split it among themselves. For each product price, they would look up their store’s price and note all the products that their competitors sold for less. It usually took a couple of days.
“You know, I could write a program to do that if you have the original file for the printouts,” my roommate told them, when he saw them sitting on the floor with papers scattered and stacked around them.
After a couple of hours, he had a short program that read a competitor’s price from a file, found the product in the store’s database, and noted whether the competitor was cheaper. He was still new to programming, and he spent most of his time looking up documentation in a programming book. The actual program took only a few seconds to run. My roommate and his co-workers took an extra-long lunch that day.
Thanks for writing this book and making it available under the Creative Commons License.
I created a lightweight system, that serves web pages, added proper authentication, storage (mongodb), memory storage/cache (redis) , simple ORM (mongoengine), automatic backend, background processing/scheduling (celery), email integration, single command deployment (automation)
I have also demonstrated how to do scrapping/scheduling/email sending in this tutorial:
https://medium.com/project-enferno/create-your-first-minion-...
and this one explains how to automate the deployment of everything you create with the framework with a single command:
https://medium.com/project-enferno/tip-deploy-enferno-framew...
Hope someone will find this helpful.
[1]:My framework is called Enferno: http://enferno.io and runs on top of flask.
You'll get the full PDF/epub/mobi version immediately, and the print book will be shipped soonish. (Or maybe immediately. They've come in from the printer and I have my author copies.)
By the way, if you have the book and are experiencing problems with `pip3 install python-docx` on OS X Yosemite, the solution is to install the Xcode command line tools first:
xcode-select --install
Then `pip3 install python-docx`
Object orientation and concepts like those are useful for big systems, but simple automation doesn't always require it.
Thanks for the pip3 tip, I'll post it on the website as I get content up.
Meanwhile, you can use PYBUTLER for a 30% discount on the book/ebook, and I'm offering a 70% discount on my other books: http://inventwithpython.com/blog/2015/04/21/celebrating-the-...
Basically, it's a book for complete beginners who don't necessarily want to be software devs but do want to automate parts of their office job. Part 1 is a bare bones Python tutorial (I skip OOP entirely) and Part 2 covers practical stuff: moving/renaming/copying files, updating Excel spreadsheets, parsing PDFs and Word docs, web scrapping, GUI automation.
I'm currently working on the HTML version of the book to be posted online, which will be at http://automatetheboringstuff.com
But at the same time, there are a lot of times where you need a very specific, one-off, 30 line script to do something for your particular job/company. This is where knowing a general (and easy to use) programming language like Python comes in handy.
Hence why I wanted to write a programming book for office workers who wanted to skip the computer sciencey and software engineering aspects. Who cares if a throwaway script is O(N^3) if N is going to be a few hundred? Most of the time these things don't matter, because it's still faster than doing this stuff by hand.
So perhaps they will be available for free from April 25th?
(My personal choice would probably be Perl for many of the tasks, though I would point beginners to Python for its readability).
But seriously, Python makes easy things easy. In bash, just to extract a substring you need to do something like echo someletters_12345_moreleters.ext | cut -d'_' -f 2 That's not very beginner-friendly.