You know, some of the things we do in life are tedious and boring.
They're the kind of things that machines or maybe robots could do.
So let's build those machines.
This is Talk Python, and we'll be automating the boring stuff with Al Swigert.
It's show number 19, recorded Thursday, July 2nd, 2015.
Hello, and welcome to Talk Python to Me, a weekly podcast on Python.
The language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy.
Follow me on Twitter, where I'm @mkennedy,
and keep up with the show and listen to past episodes at talkpythontimmy.com.
Also, follow the show on Twitter, where it's at Talk Python.
This episode, we'll be talking with Al Swigert,
author of Automate the Boring Stuff with Python,
Practical Programming for Total Beginners,
and founder of inventwithpython.com.
This episode is brought to you by Hired and CodeChip.
Thank them for supporting the show on Twitter via
at Hired underscore HQ and at CodeChip.
Now, before we get to the show,
I do have to apologize for my audio on this one.
The gain on my mic got bumped, and unfortunately, I didn't notice until after the interview.
Luckily, Al's audio is great, and I let him do most of the talking, so it's not too bad,
but the quality is definitely below the bar I try to set for this show, so I'm sorry about that.
Now, let's get to the show.
Let me introduce Al.
Al Swigert is a software developer and technical book author living in San Francisco.
Python is his favorite programming language, and he is the developer of several open source modules for it.
His other books are freely available under the Creative Commons license on his website, inventwithpython.com.
His cat weighs 14 pounds.
Hey, Al. Welcome to the show.
Hey, thanks for having me.
You bet. You got a big cat, man.
Oh, yes.
In Chapter 17, which deals with image manipulation, I use a photo of her,
and she looks especially rotund in that photo, but I have her on a diet now, so she's down to 13 pounds.
Oh, at least it's going the right way. That's cool. I love big cats.
Oh, yeah. I'm pretty sure she might be, like, two cats under a trench coat standing on each other's shoulders, maybe.
That could account for the weight.
Yeah, that's the most likely scenario, I think.
All right. Well, welcome to the show.
Today, we're going to be talking about your new book, Automate the Boring Stuff with Python.
And you just released this, right?
That's right. It came out this past April.
I've been working on it for about a year and a half beforehand.
And, in fact, March of 2014, I left my software developer job to start writing full-time.
I think that's a really brave but awesome thing to do.
Yeah. It was a calculated risk.
I mean, for the decade beforehand, I'd always been working a safe 9-to-5 job.
And so I had some money saved up, and so I thought, well, now's the time to start taking some risks.
That's right. The whole learn-to-code thing is hot.
You're probably at a place in your life where you're able to take that time and focus and so on, right?
Yeah.
So we're going to talk all about your book and some of the other projects that you've got going on.
But before we get there, how did you get into programming in Python? What's your story?
So I started programming sometime in the third grade, and I really don't like telling that story because it sort of reinforces that, like, oh, no, you have to start programming when you're a little kid or, you know, just as soon as you develop motor skills or something if you want to get good at it.
So I always follow that up with all the programming knowledge that I gained between the third grade when I started and probably freshman year of university.
You could probably learn that in every weekend for a few weeks.
So it didn't really give me that much of a boost, but it was definitely something I had been interested in for a while.
So I had started with BASIC, and I found this one book that was really great at teaching me how to program.
And this was, you know, before Google and before you could easily find a lot of information.
I didn't even really know that I was specifically looking up books on programming because whenever I went to the library and thought, okay, I'll just find computer books, they would just be sort of abstract and say, like, oh, this is the CPU and this is the printer and this is the keyboard and that sort of thing.
It wouldn't actually be talking about loops and variables and other things like that.
But this one book I found, it was great.
It just gave me the source code for all these small little games.
And just from that, I was able to copy that code and then make tiny adjustments to it.
So a few years ago, a friend of mine was the nanny for this precocious 10-year-old who wanted to learn how to program.
So I tried to find some tutorial on programming like that, but I really couldn't find anything.
So I just started writing up a short Python tutorial, and that just eventually ballooned into book length.
Which I just self-published.
And people seemed to really like it.
So I wrote a second one and then a third one.
Now you have a habit.
Yeah, yeah.
I kept thinking, like, okay, this will be the last book I write.
And then, oh, well, I got to come out of retirement to pull off one last heist.
So that was Automate the Boring Stuff with Python.
Yeah, that's really cool.
What was the name of the original book?
The original book that I found was Invent Your Own Computer Games.
And back before I realized that this could actually become a huge book.
So my first book was just Invent Your Own Computer Games with Python.
And by the time it had blown up a little bit, I already was kind of stuck with that name.
But it's worked out pretty well.
Yeah, that's awesome.
I think it's really inspiring to help young people kind of get started.
It sounds like that's where your book came from.
Yeah, it's really great to get emails from people who say, you know, like, I'm 14 years old and I want to learn how to code.
And I essentially copied the style of that book of just having the complete source code to small programs instead of just only talking about programming concepts abstractly and then leaving it up to the reader to put all those concepts together to actually make something fun.
Yeah, I think one of the hugest problems learning to program, and it doesn't really matter whether you're a kid or not, is in order to do anything that is at all interesting or seems like you've accomplished something, you have to learn a bunch of little tiny facts.
Oh, yes.
Yeah, I've got to learn what a for loop looks like.
I've got to learn how to clear variables.
I've got to learn how to import modules.
And you've got to power through that stuff.
And somehow, in your mind, you have to say there will be something good on the other side.
And I think the kind of stuff that you're proposing gets, you know, shortens that gap.
And so fewer people are likely to drop out, I guess.
Yeah, I mean, I definitely tried to keep all the, in the first book, all the little game programs anywhere between 50 and 200 lines of code.
I don't think any of the programs are more than 200 lines of code.
Just because you don't really have to have that much code to make something a lot of fun.
And Python is actually great about this.
When I started writing up, like, a hangman program or a tic-tac-toe program, I realized, oh, wow, if I had written this in BASIC or in some other old programming language, this would have been probably about three or four times as long.
And just that much more that I would have to explain in a book, and I would lose, you know, another standard deviation of readers.
That's right.
Here's how you import the header file, and here's how you link the static library.
Oh, right.
And it's like, oh, no, we're done.
And just type out public static void main string args bracket bracket.
We'll go into why later.
Yeah.
Python's great.
Just, you know, hello world is one line.
Yeah, Python is great.
What I really think is cool about it is it's appropriate for this, like, my very first experience in programming.
And as you probably know, Python is now the most popular language for first year programming courses at universities in the U.S. at least.
Right?
Oh, right.
Yeah, that's awesome.
But it's...
It's eclipsed Java in that regard.
Thankfully.
And it's also appropriate for Instagram.
And it's appropriate for discuss.
And, like, these huge scale professional things.
Right?
So the fact that it's a spectrum that you don't like, okay, I'm going to learn Scratch until I want to put on my big boy pants.
And then I've got to go learn Java.
Right?
It's this continuum that is wonderful, I think.
Yeah.
I mean, so Python, as you might know, was just based off of this language ABC, which was developed as a teaching language.
And it turns out that making a language's syntax just easy and readable is not just good for beginners, but just a good idea in general.
Right.
It basically comes down to the realization that code is read way more than it's written.
Oh, yes, definitely.
Yeah.
Definitely.
So let's talk a little bit about your book and some of the topics that kind of surround it.
Sure.
Yeah.
So one of the things that you said is, you know, people feel like, what's your quote, that programming is something like intimidating rocket surgery.
And it's just scary.
But probably it shouldn't be.
What do you think about that?
It's, yeah, programming definitely has that sort of, you know, you have to be a genius in order to understand this.
And I suppose a lot of people are less intimidated by computers these days.
Just because they're more familiar.
But the idea that I can write software, you know, just like Mark Zuckerberg or Bill Gates can write software and go on to, you know, they, you think that you would have to be a genius in order to program a computer.
And then that goes on to create a billion dollar company or anything like that.
Whereas, you know, there's a wide spectrum where, oh, yeah, you could just write little scripts using some, a few programming concepts.
And these scripts can actually be pretty useful.
So I started thinking about, well, what kind of things could a typical office worker write?
I mean, a lot of my non-programming friends would tell me, you know, like today at the office, I spent four hours going through a couple hundred Excel spreadsheets and copying and pasting this one line out of all of them.
And I would think to myself, like, oh, wow, you could probably have written a script to do that in 20 minutes.
And it would have taken about two seconds to run and you would have been finished and saved yourself an entire day of work.
That's right.
Not just that day, but every day going forward.
Yeah, exactly.
In your book, you have a cool story about some college roommates working in retail.
Can you remember that?
Can you tell it?
Oh, yes.
Yeah.
So this story is at the very beginning of the book.
It's one of the things that I remembered when I started writing this.
This was, I think, my sophomore year college roommate.
He was telling me about how he was working at this one retail outfit.
And every once in a while, they would get a huge spreadsheet of product prices of their competitors.
I didn't ask how they got this spreadsheet.
But they would have to go through and type in each, you know, product SKU into their database to find their price.
And then they would have to compare the prices.
And they'd just mark it out on these massive printouts that they made of hundreds of pages.
And it would be two or three of them just doing this for two days straight and going through and then just checking to see which prices they should lower in turn.
And he said, well, you know, if you have the original file that you printed these pages out from, I could probably just write a script to go through and automatically do this.
And, you know, so it took him like a couple hours.
And he was just most of that was just consulting documentation and trying to remember how to do various things in C.
But eventually he just hacked out a tiny script.
I mean, it was basically look in this spreadsheet, look in this database, and then just see which one's higher and then print out the relevant ones to the screen.
So, you know, after a few hours of just writing that code and he ran it and it only took a few seconds to run.
And he basically just sort of saved everybody, you know, multiple people, a couple days of work.
Yeah, that's fantastic.
Yeah.
And so computers are at this point, everybody, you know, is familiar with has access to computers.
Lots of people have laptops.
Lots of people have mobile phones.
But a lot of people don't get the maximum use out of them just because they have to rely on software written by other people.
So even if you don't want to become a software engineer, though, learning how to program will allow you to make, I don't know, turn it into a much more useful Swiss army knife that can do anything that you need it to.
There's a lot of people out there like that.
You know, if you're a lawyer, if you're a doctor and you run a small practice, there are all sorts of things behind the scenes that have nothing to do with lawyers or nothing to do with being doctors.
But they have to sort of manually go through all this business-y data stuff.
And that'd be ideal for what you're proposing, right?
Exactly.
Yeah.
It's pretty good when I describe what the programming book is about.
And it's like, oh, well, it's programming little scripts to automate tasks for people who don't want to really become software engineers.
They just want to automate things.
And a lot of people would tell me like, oh, yeah, that actually sounds like a great idea.
So it was really helpful just sort of nine months into writing this.
And I have no idea if the world needs yet another programming book or something like that.
But it's worked out pretty well just because I think a lot of people recognize that large software companies aren't going to write software that does their particular tasks because they have such a specific workflow that's specific to their own practice or their own organization.
But they would just need a 20-line script to do something.
And they don't even know what it has to do until suddenly they're faced with this task.
So just if they had those programming skills themselves, they could work it out themselves.
Right.
I mean, otherwise, they're probably paying thousands of dollars and hiring a consulting company.
Or they're going to somewhere like Elance.
And they're like, have no idea what they're getting.
And maybe even more likely they're just not getting it done.
Right.
Oh, yeah.
And once you're going to spending that large amount of money, you sort of want a large application when even that's not necessarily what you really need.
Yeah, that's right.
So you really stuck true to your original vision for the book in terms of how you chose topics and how you presented them and how you taught Python.
So you threw away a lot of the traditional OO, design pattern, fancy style of programming.
And you said, well, if you're only writing 100 lines of code, what do you really need?
Yeah.
This episode is brought to you by Hired.
Hired is a two-sided, curated marketplace that connects the world's knowledge workers to the best opportunities.
Each offer you receive has salary and equity presented right up front.
And you can view the offers to accept or reject them before you even talk to the company.
Typically, candidates receive five or more offers in just the first week.
And there are no obligations ever.
Sounds pretty awesome, doesn't it?
Well, did I mention there's a signing bonus?
Everyone who accepts a job from Hired gets a $2,000 signing bonus.
And as Talk Python listeners, it gets way sweeter.
Use the link Hired.com slash Talk Python to me.
And Hired will double the signing bonus to $4,000.
Opportunity's knocking.
Visit Hired.com slash Talk Python to me and answer the call.
Oh, yes, exactly.
Like, for example, I don't go into object-oriented programming at all.
I think I might briefly mention it at some point in the book.
But I don't talk about classes or anything.
I skip list comprehensions and a whole bunch of other Python nifty little features.
Just because you really don't even need that.
I think somewhere in the first chapter I say something like,
well, using global variables is kind of bad once your programs get big.
But go ahead and do it.
You're not going to be hurting anything.
Just to keep things really simple.
Yeah, that makes sense.
By the time you understand why this is a problem and you know how to fix it,
you're going to be doing something different anyway, right?
You may never reach that point.
So why impose all this structure?
I mean, that's kind of why Python and starting with Python is cool,
is you can start easy but scale up, like I was saying,
to these high-end, full, large-scale web apps, right?
And so you should maybe take that same approach
from a how-do-you-write-code perspective as well.
Right, and I was just always sort of suspicious
whenever I started learning a new language or something like that.
I would go to a library or bookstore and try to find whatever books,
and I would notice like, wow, there's 600, 700-page books on C++.
Do I actually need to know all of this right from the start
in order to start writing code in this?
Yeah.
So I really wanted something that just kept to the basic minimum.
Yeah, and what's crazy about that C++ book
is it was probably just the language.
You still couldn't create a web page.
You couldn't host a web page.
You couldn't talk to a database.
You couldn't show UI, nothing.
Yeah, exactly.
It was just a lot of syntax and maybe the reference material
for the standard librarian.
Yeah, but let me tell you,
you could sure create your own operator overload at the end of that.
But still, no window.
Yeah, you'd have no idea why you'd want to make that.
Yeah, exactly.
Yeah, so I mean, a lot of those books are made for software engineers
who already know how to program
and sort of know all of these concepts already.
Yeah.
So one thing I thought was cool about your book
is you were using Python 3.
Yes.
Yeah.
Yeah, I made the switch to Python 3,
I think about four or five years ago.
Wow, yeah, Python 3 has been out that long.
It has.
Like what, 2008?
Yeah, originally the first book I wrote was using Python 2
and somebody recommended like,
oh, hey, why don't you make it for Python 3?
And I thought, oh, yeah,
that's one of those simple and obvious things.
So I've been working a lot with Python 3.
At my last sort of day job,
we were still using 2.6, I think.
And that's just because we had a large existing code base.
And I didn't realize how many people were still in that same boat
until I was at PyCon recently in April of this year in Montreal.
And I think during the keynote,
the speaker asked the entire room of, you know,
several hundred people,
how many people are on Python 2
and how many are on Python 3, just a show of hands.
And it looked about 80% of people were just still using 2.7.
And just like a tiny minority of the room was on Python 3,
which was sort of astounding for me.
So I'm very specific and particular about telling people,
if you're going to start a new project
or you're just learning how to code, go with Python 3.
I mean, at this point,
a lot of the major modules now have Python 3 support.
So the old excuses of like,
well, if you want to learn how to use such and such library,
then you're just going to have to use Python 2 anyway.
So you might as well start with that.
So I completely recommend people picking up programming to learn Python 3.
Yeah, that's awesome.
And I totally agree with you.
You know,
I put together my website for the podcast using Pyramid and SQLAlchemy
and various other packages,
all Python 3,
no harm.
But I understand if you've got a million lines of Python 2 code,
you might not want to go mess into that.
So it depends whether you're new,
whether the project is new.
There's a lot of variables there.
Yeah.
But I think it's cool that,
you know,
you're at least starting people off down that path as the default.
And then maybe they've got to change for some reason.
Kenneth Wright was talking about an interesting data point.
The Django guys,
they traditionally had their documentation in Python 2,
and they switched it to Python 3.
Just by switching the documentation's default view to Python 3,
it increased the usage or something like by 4% of Python 3.
It was like,
wow.
Maybe it was only for Django.
Or it was for,
I think it was for Python in more general.
I have to look at the graphs again,
but it was pretty crazy.
Yeah.
A tiny push in this direction.
And I think that's a lot of the things is that Python 3 isn't,
I mean,
it has a lot of new and great stuff in it,
but it isn't so completely new that it has a,
has a lot of killer features where people are thinking,
we must go to Python 3.
A lot of the times people say,
well,
Python 2 is what we know,
so we'll just go ahead and stick with that.
So I think that it just needs to get that inert,
initial inertia going.
Yeah.
I'd love to see some killer feature come into Python 3 only and,
and really encourage people to switch.
But like you said,
I don't think we're there yet.
Yeah.
so one thing you do in the book that I thought was really interesting.
And I think most programming books would absolutely skip,
but makes such perfect sense for the audience and experience level that you're
targeting is you actually teach people how to use Google and stack overflow to get
programming answers.
Yeah.
That,
that,
that came from,
uh,
I put my email address in my,
in my first book and I said,
Hey,
you should just go ahead and email me,
uh,
if you have questions.
And so I would get,
uh,
emails from people.
And I remember growing up,
I had like RTFM shouted at me on an IRC channel all the time.
And I was thinking like,
Oh,
that's really obnoxious and annoying.
Um,
but I could see the,
the intent behind that was to make people more self-sufficient.
Um,
so I would get a lot of questions where people would say like,
how do I do this?
And I thought like,
Oh,
well,
here's the terms that you can Google.
And so at the very beginning of the book,
I sort of wanted to help people say like,
okay,
so programming might be hard at times,
but you can always just Google for,
you know,
if you get some error message,
which will never make sense whatsoever,
like,
uh,
the common example I use is if you forget to put the ending quote on a string,
the error message isn't,
you forgot to put a quote,
uh,
to end the string.
It's,
it's something like E all,
uh,
syntax error at unterminated string or something like that.
And you have no idea,
like,
even if you're a native English speaker,
you have no idea what that means.
So I just wanted to say,
look,
it's okay.
You can just copy and paste that entire message into Google and you'll find a bunch of websites where people
have had this exact same problem.
Uh,
the top three results will probably be stack overflow.
Uh,
and then they can just learn of like,
oh,
there's a site stack overflow and I can ask questions there.
Um,
especially because after a while I noticed people would be emailing me the same questions.
So I thought,
oh,
well,
it's not really efficient for me to individually send out this answer each time.
So making people more self,
uh,
self-sufficient in finding answers for themselves,
I thought was something I wanted to have right at the start of the book.
Yeah,
that's really cool.
And you know,
it's as programmers,
we know that you can put insane stuff in and search for it.
But when you were learning,
you know,
you don't necessarily know you can just put like an error code or other bizarre stuff into Google and get insanely detailed answers.
Yeah.
one time I had a friend who had,
um,
outlook,
like small business edition match with some weird thing on windows.
And it like went crazy and lost all of his email.
And he said,
I know you're not really into this,
but I know you know computers.
Well,
cause you just look at this and help me.
I'm like,
geez,
I don't mean I'm not an outlook person.
I don't really know,
but it came up and said,
you know,
error,
OX,
that had some huge,
long hexadecimal error code or something.
So I just typed outlook and that thing into Google and bam,
there was the exact steps to fix the problem.
And I'm like,
look,
just what you can do.
Just,
and he's like,
how is this even possible?
Right.
It's just,
you know,
we take it for granted,
but I think it's cool that you show people how to do that.
Cause it's surprisingly effective.
Yeah.
I mean,
I had a friend,
uh,
she wasn't a programmer,
but she worked at a biotech startup and wasn't,
uh,
there as in an IT role or anything like that,
but she effectively became this small company's IT department.
I think because she was the only person who wasn't afraid to just Google how to do stuff.
Whereas everybody else was just like amazed and thought she was really great at computers or something.
It's like,
no,
she can just sit down and she's not afraid to say,
you know,
Google for SharePoint server set up and just do all the,
yeah,
follow all the steps.
Yeah.
That's awesome.
I,
one of,
there was some study done that said,
you know,
what is the most important,
uh,
personality trait for successful startup founders?
And,
and basically for people creating companies and what was the most tech companies in particular.
And it turned out the most important thing was simply persistence,
not being super smart or whatever.
Right.
Just having that tenacity.
Yeah.
And this is part of it.
Like,
I'm just going to keep searching,
keep digging until I get there and just being effective.
That's cool.
Another thing that you have in a lot of the sections is you've got like practice questions
and you've got even challenges.
So that's really nice to have some hands-on component.
Yeah.
I didn't have those in the first couple of books I wrote and I kept getting emails from
people who said like,
Oh,
it'd be great if I had practice questions.
I always thought that was just something that,
you know,
was,
was sort of just filler and nobody actually really followed through with those.
I remember whenever I read programming books,
I would kind of like,
you know,
answer a few of them maybe,
or sometimes I'd just skip them.
But a lot of people started thinking like,
Oh yeah,
it'd be great to have those practice questions.
And also I would get teachers and professors saying,
Oh yeah,
I love your book.
It's great.
I'm using it for,
for this course,
but there's no practice questions or,
or any exam material or things like that.
It'd be great if,
if a book had that.
So that really opened my eyes to just how many people could,
could find this information useful.
And also I,
I wanted to sort of keep focus on having the,
the source code to actual programs,
um,
and not just have this be a laundry list of programming concepts that,
that I just,
you know,
Oh,
these are loops.
These are variables.
These are functions.
Uh,
and,
and have it as just that I wanted to have actual complete programs as well that
people could,
could see.
Yeah,
that's great.
Do you have your,
uh,
finished examples and programs on something like GitHub?
Uh,
they're on the no starch.com,
uh,
slash automate stuff website.
Okay.
Uh,
there's a link there.
It says like,
here's the zip files for,
for all the,
all the programs and things.
That's cool.
So people can go download them.
Yeah.
Nice.
so we talked a little bit about why you chose Python over other languages,
but there,
there's certainly,
it seems like there might be some trade-offs.
Like,
suppose you want to do that work with Excel.
I know if maybe you chose something like.net,
you could use like the,
the calm integration on windows to directly integrate with Excel and stuff like,
you know,
what,
what were your,
what was your thought process of choosing Python over the other various things?
I,
to be honest,
I really didn't spend that much time thinking about it.
Uh,
mostly because Python was,
was such an obvious,
uh,
first language to learn.
It has a,
it has such a great learning curve,
um,
that I thought,
well,
everything else I can just kind of figure out after that,
because I didn't want to choose,
go with a different language just because it would make some other things easier.
I thought,
well,
Python's great.
It's,
uh,
it's mostly the same.
if you have windows or a Mac.
Yeah.
The cross platform part of it's really nice.
So,
yeah.
And,
and it turns out there's,
there's plenty of modules for doing things like working with Excel spreadsheets and reading
word documents.
Uh,
yeah,
that was actually a little surprising to me because I've never tried to work with Excel
from a Python,
but it sounds pretty easy.
Maybe you could talk a little bit about the,
uh,
the second half or second segment of your book.
So the first half is all about,
here's how you get started with programming.
Here's like loops and in a really approachable way,
but then you get into like,
let's automate some things.
Can you talk about some of the things?
This episode is brought to you by code ship.
Code ship has launched organizations,
create teams,
set permissions for specific team members and improve collaboration in your continuous delivery
workflow.
Maintain centralized control of your organization's projects and teams with code chips,
new organizations plan.
And as talk Python listeners,
you can save 20% off any premium plan for the next three months.
Just use the code talk Python,
all caps,
no spaces.
Check them out at code ship.com and tell them.
Thanks for supporting the show on Twitter,
where they're at code chip.
Yeah.
I mean,
I wanted the book to be for complete beginners.
So I have that first part of the book,
which is assuming you don't know anything about programming whatsoever,
but I thought,
well,
it'd be nice to actually have like in the second part,
go into all these different third party modules that make doing all these different tasks easier.
So there's,
there's a chapter on web scraping using Selenium and beautiful soup and requests.
And,
and then also another chapter on using OpenPy Excel to work with Excel spreadsheets and things like that.
I was really surprised at how many modules were out there that,
that were actually pretty high quality and projects that I hadn't really heard of before until I started looking for them.
And so a lot of the,
a lot of the initial work of writing out this book,
was just going through and mapping out,
okay,
what are the problems that have to be solved?
What modules are available out there?
And Python is,
is pretty well supported in that regard.
Yeah,
I think you're right.
I think the whole PyPI package stuff,
I mean,
there's 56,
57,000 of those,
right?
A lot of them.
Yeah.
And it's,
it's great.
There was the whole XKCD cartoon about Python where he just typed import anti-gravity and you,
that kind of,
that kind of sums it up,
right?
Yeah.
there's the,
the concept in,
in a lot of the Python documentation of Guido's time machine where Guido Van Rossum,
the creator of Python would commonly reply to email lists when people said like,
I'd really need a module to do such and such.
And he would reply like,
oh yeah,
I just committed a module that did that last night,
leading a lot of people to think that he actually has a time machine and can start writing these code,
this code before you even think of it.
Yeah.
That's awesome.
You've got this book.
You have your two other books.
You also said you've done a couple of open source projects or packages for Python.
Do you want to speak about that a little?
Yeah.
What became the most popular of them so far is,
is one that I actually wrote for the book.
It was for chapter 18 on,
on controlling the keyboard and mouse.
I found a lot of code out there that,
well,
I wanted a module that first worked on Python 2 and 3 and also worked equally well on Windows,
Mac,
and Linux.
And so I would find a lot of great modules,
except,
you know,
some of them would only be for Python 2,
or some of them would only be for a particular operating system.
or sometimes the API was,
just had a bunch of odd names for things.
So I wanted something really simple.
So I created PyAuto GUI,
which gets a few thousand downloads each month now,
and especially now that the book is out and covers it.
But it was basically just taking all the best parts of code from all these various modules
and putting them into this unified interface.
So you have,
and it's really simple.
You just import the module and it has a click function or a typewrite function to just type out an entire string.
Or if you want to press down certain keys,
those are all just single functions.
So I really like that.
Before I had started writing this automate book,
my second book was on PyGame.
And so I'd written a few modules for that,
which one,
which was PigCurse,
which is sort of a curses emulator,
except built on top of PyGame.
And that was just so that I could have some way of writing text to a certain cell.
Like I could tell the cursor to go to some XY position and then start typing out things like that.
Just because again,
you know,
Python has curses,
but then for Windows,
there's a separate console module
that you would have to install.
So there's no unified thing that just works on all operating systems.
And then also,
there was a PigAnim,
which is a sprite animation module that I made for PyGame.
Nice.
For building like 2D,
little side scroller apps,
that kind of thing.
Yeah,
well,
it's basically just to be able to take like an animated GIF and put it into your program.
I mean,
PyGame is great because it would make it really easy just to display an image in a window somewhere.
But if you wanted to have,
you know,
a little like animation of a running character or something like that,
you would have to program all that logic in yourself because PyGame was fairly bare bones.
And I looked around and I saw that nobody else had made something like this in particular for PyGame.
So I just started that as like a week long project.
And I've written a few other modules,
but,
you know,
they're all just really tiny and just have like,
you know,
a hundred downloads a month on PyPI.
But yeah,
just a lot of really simple things.
Yeah,
that's really great.
All right.
Albert,
I think this might be a good place to wrap it up.
But before I let you go,
let me ask you a few questions that I typically ask people on the way out.
In addition to PyAuto GUI,
what other PyPI packages are your favorite or most useful or you think,
you know,
people maybe don't know about you should tell them about?
Oh,
I think really at the top of that is Selenium.
The web scraping chapter on the book's website,
I think the web scraping chapter is the most popular one.
And so Selenium basically launches Firefox or,
or a different browser and lets you programmatically control it.
So you could just automate doing web scraping or filling out forms or anything like that.
And I'd heard of Selenium and other things before,
but I always thought like,
oh,
it must be this really complicated thing that you have to,
you know,
spend an entire weekend reading up on.
I didn't realize,
oh,
actually,
no,
it's about,
you know,
four or five different functions that you have to learn.
And then you can pretty much,
and then you're set after that.
So Selenium is,
is definitely one of my,
it's,
I'm completely amazed at how much you can do with it,
even with,
you know,
a very little knowledge and very little time learning about it.
Yeah.
That's awesome.
It seems like you could almost do like basic load testing,
integration testing,
other types of sort of web automation with it,
right?
Oh yeah,
exactly.
I mean,
because it's actually launching a,
a web browser,
you can have it work with whatever browser plugins you have,
or it'll run JavaScript on the page.
So,
you know,
it's not just downloading files from a URL.
You can actually simulate the JavaScript as well,
and then see how it looks like for the,
for the user.
It's,
it's a really great module.
Yeah.
That's excellent.
Yeah.
Make all those,
uh,
client side spa type apps actually show what they're supposed to show.
Right.
Yeah.
Nice.
Okay.
Uh,
next one.
Uh,
are you,
what kind of editor are you using these days?
Uh,
I really like sublime text.
Um,
I mean,
for the longest time I use this one text editor called edit text,
which was sort of like notepad plus plus.
Well,
not like there is actually an editor called notepad plus,
plus,
but it was all the things,
uh,
I'm on windows.
It was all the things of notepad.exe,
except it had a light,
a lot of other nice features,
but it was still fairly lightweight.
I've never actually gotten around to learning,
uh,
Vim or Emacs to any great extent where,
you know,
I can sit down and use them,
but I,
I think I like using the mouse too much.
Yeah.
I hear you.
Okay,
cool.
Yeah.
I like sublime as well.
It's really nice.
Yeah.
And in the book,
I just say,
go ahead and use idle.
Um,
because it just comes with Python if you're on windows.
And so you don't have to,
you would have to do any setup or configuration,
which is really nice.
Yeah.
That is great.
And it's all,
it's all about reducing the friction and getting people to like have those moments of,
Hey,
I've created something rather than why do I care about how to declare a string?
Yeah,
exactly.
That's awesome.
Okay.
So what,
what do you want to give a final shout out to let everybody know about your book,
obviously?
Oh yes,
definitely the book.
Uh,
it's released under a creative commons license,
so you can actually read it online at automate the boring stuff.com.
Um,
but also I'd like to just encourage people to go ahead and make it out to PyCon.
It's,
it's a really great conference.
Uh,
you don't have to be a heavy technical person to,
to get a lot of benefit out of.
And the people in the community are really wonderful.
Yeah,
that's awesome.
I would like to second that as well.
And this year it's in Portland,
Oregon,
which is my hometown.
And so that's pretty awesome.
And I'm trying to get together a,
some kind of session.
That's like a,
a panel discussion,
live podcast presentation.
So maybe I'll be able to pull that off.
That'd be fun.
Oh yeah,
that sounds great.
Yeah.
People should definitely come to it.
It'll be great.
And then I also want to encourage people to go check out your book and maybe even buy it,
right?
Like you,
you've done some really cool stuff.
Yeah.
And it is available,
you know,
sort of separate pages as HTML and you can check it out,
but you know,
it's not that much.
So support the work.
Yeah.
A lot of people really like having it all combined on their Kindle or just having the physical book in their hand.
Right.
Absolutely.
All right,
Al,
thanks for being on the show.
It's been fun.
Oh,
thanks.
Yeah.
It's been a lot of fun for me too.
Yeah.
Bye.
Today's guest was Al Swigert.
And this episode has been sponsored by Hired and CodeGip.
Thank you guys for supporting the show.
Hired wants you to find your next big thing.
Visit Hired.com slash Talk Python to me and get five or more offers with salary and equity presented right up front and a special listener signing bonus of $4,000.
CodeGip wants you to always keep shipping.
Check them out at CodeGip.com and thank them on Twitter via at CodeGip.
And don't forget the discount code for listeners.
It's easy.
Talk Python.
All caps.
No spaces.
You can find the links from today's show at Talk Python to me.com slash episodes slash show slash 19.
While you're at it,
be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes and direct RSS feeds in the footer of the website.
Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
You can hear the entire song on our website.
This is your host, Michael Kennedy.
Thanks for listening.
Smix takes us out of here.
We'll see you next time.
First of all, first of all, first of all, first of all, first of all, first of all.