Transcript: Python Crash Course - Eric Matthes
Hello and welcome to another episode of Django Chat, the weekly podcast on the Django web framework.
I'm Will Vincent joined by Carlton Gibson.
Hi Carlton.
Hello, Will.
And this week we're joined by Eric Mathis.
Uh welcome, Eric.
Good morning.
So I we wanted to have you on for a long time.
You are uh most notably the author of Python Crash Course, the best-selling Python book in the world the last few years.
But you also were involved with PyCon, Django teaching, so there's a lot to dive into.
And maybe we could start with how'd you get into programming?
I got into programming in the late 70s, early eighties.
Uh my dad was a programmer and he had a computer in our house before anybody else had PCs.
It's a little kick computer in our basement.
And so I learned basic.
I learned basic because I watched my dad tap keys in the basement and it looked like magic.
So I asked him how the magic worked and he showed me.
And I really appreciate that uh early beginning.
Hmm.
And then you and you grew up, is it New Hampshire, I believe?
Yes.
I just asked because I'm from Vermont, so I I like people from our neck of the woods.
Yes, I always hear I always enjoy hearing where are you from stories because like I think of you as from Boston.
Yeah.
So I would say, you know, or if I went overseas, I would say it's you know in between Montreal and Boston.
Kind of somewhere in there.
Right.
Um or you go out out outside the New England and you know, no one has any idea of which you know, Vermont or New Hampshire which is which.
Right.
Why should they?
Even in Virginia.
Anyways, sorry.
So you so you got a yu a young start and then but there wasn't formal education for computer science back then, I don't think, right?
Well, I feel rather fortunate.
So my dad was a software engineer in the 70s, and so learning basic was nice.
Um one of my clear memories was building a number guessing game when I was young.
Um and what I remember from that, I don't remember anything about the programming beyond like line numbers and go-to, but I remember getting up from the computer, having my parents sit down and play the game that I had written.
And when it worked, I remember this feeling um of creating something that other people could use.
Um and that has been a satisfaction that I remember to this day.
And so when I introduce other people to programming, I I if it's in a classroom, I enjoy watching them get to that point of their first program that works that other people can see.
Um and for readers, I love uh hearing their stories of the things that they build working.
Um Yeah, I I think of that as the aha moment.
If you can not not just get that, but periodically have those as you're teaching concepts, like it actually worked.
Maybe I don't understand how it worked, but it actually worked and I can share it with someone.
That's what keeps someone kind of engaged on the long, lonely quest of programming.
Yeah, and if you do it right, um, you know, when I was teaching math um and teaching problem solving, I tell people that it's a creative act.
If you're gonna solve a problem that you haven't solved before, you have to have some spark of an idea for how to approach that.
Um and so for programming, for anything where people don't give you the character to type in, you have to have some of that same intuition.
And so that that first program that you wrote, no matter how small your part of it was, um, it working as validation and and encouragement.
Um but for my programming, um, I grew up when logo was being introduced to schools.
And so I think we had probably some Apple Apple IIs or something in our elementary school classroom.
Um and so the um, you know, when I got to high school, I think I had computer science classes.
I remember clearly um in college, I went for a BS in physics.
And so that was in the early 90s, and so we had to take a variety of programming classes.
There was C, Fortran, Pascal.
Um, and I didn't do a whole lot with those, but I got a decent grounding in all those concepts of what a variable is, how it interacts with the physical memory of a computer.
Um And I'm grateful for, well, that I'm I'm very happy that people these days don't have to start with those lower level languages if they don't want to.
Um, but I'm grateful for having had um that early, early background in um how all this is managed and structured within a a programming language.
Well, and it it must have helped a little bit that you'd already programmed beforehand um with your dad and otherwise, because uh I mean this is the uh currently I think the great divide in an undergraduate computer science program, let's call it half of students have programmed before.
And maybe they're just you know it used to be PHP or they're banging around with something, but they've got those aha moments.
They kind of have some context, even though they don't really understand why.
So when they do learn the fundamentals, it's things click for them and connect in a way that if it's the very first time you're programming, you don't really understand why you're at that lower level.
Yeah, I think you're if
you agree with that statement, but I've I see that as you know, it's if you if you have that context initially, it makes it easier, but also you have the perspective to understand why you would bother gutting through a you know data structures or whatever class that you know weeds out people um first or second course at the undergraduate level.
Yeah, I am always careful offering opinions on this because I didn't go through that.
So but
no one on this podcast didn't.
But you know, I did okay, so I studied physics um and I got there because I had a chemistry class in high school that I really liked.
I had an AP chemistry class, and the teacher focused on how we think.
So I learned critical thinking really well from uh a really good chemistry teacher.
And so when I got to college, I um started out in chemical engineering because I liked chemistry and I thought, okay, I want to apply this.
Um and I got to my chemical engineering class and it was all about like running nuclear power plants.
And um I thought I do not want to run a nuclear power plant or a petroleum plant.
Um and I found that my my introphysics classes were all about understanding how things work.
Um so that was my first real understanding of the difference between engineering and pure science.
Um and so the gatekeeper classes for that was calculus and introphysics.
And so these were classes that I loved.
Um I mean, I just loved math and science for just understanding the world.
And I had the good fortune of having good teachers who are supportive and having a a decent intuition for these subjects.
Um, but I I was surprised, I think, when I got to college to see how viscerally some people hate these subjects.
And I started tutoring, and it's interesting that tutor has a 19, 20 year old because you end up a lot of the people you end up tutoring are people older than you.
And that's a really interesting position to be in.
Um and as I was tutoring, I found that people liked this subject, but they didn't like how it was being presented, and they didn't like the obstacle that it was putting up in their lives for what they really wanted to do.
And so I think there's a good parallel between that, uh that kind of gatekeeping in math and science and the same kind of thing we see in computer science programs.
I had a similar experience teaching logic to undergraduates.
There was this kind of in the philosophy department at the university I went to, there was a intro to logic, because you have you know, you have to do symbolic logic.
And half the students there were kind of maths background, you know, they go they really just plowed through it and they all got 100% in the exam.
And the other half were there doing an arts degree and they had no interest in logic at all, and they didn't want to know anything about it.
And you could see, you know, you try if you missed, if you lost one at a particular step, they'd sort of never recover, and it was difficult to could to loot fill in the building block, and it was really but it was these two kinds of people.
It's like I'm I'm turned off against this, I'm not interested.
I hate it.
And it's like, but it's fun, it's easy, it's you know, it's the easiest hundred percent you'll ever gonna get.
Yeah.
In a way.
At that level it was, you know.
Well, I appreciate the question because I do have a clear thought.
Um, you know, I think the people who learn programming before they get to college, before they get to a CS program, when they get to their CS classes, they get to focus on the CS concepts.
Um and people who have not learned to program, they have to sort out all the things that go into programming, programming environment, um, compiling, set up your computer, actually writing code and take in all the CS concepts with that.
Um that influences my thinking around like how would I design a high school um computer science um program.
I think there's a temptation for a lot of high schools to try to imitate a college environment and jump right into CS concepts.
And if I were to design a high school CS curriculum, I would focus on all the things you can do just as a programmer, all the things you can build, all the problems you can solve, and leave the hard CS um to when people get to to university.
Yes.
It's I mean it's almost mystifying why that's not obvious to people.
And I can only assume that it's some degree of it's been so long since they own that mindset.
Or you know, they just there's yeah, I mean, it's like pre-select.
If you can grind through a computer science curriculum uh curriculum and you find it interesting, you've already checked a bunch of boxes, so maybe it just never occurred to you that people would wonder, well, why would I do this?
Or what's the you know, what's the benefit for all this?
Um so I mean I know you feel the same way.
Like I feel you know, teaching this stuff that in many ways it's a benefit that I have zero formal background or even teach in a formal environment because I'm not limited by any of those things.
And so while there's a understanding of the copus of knowledge I feel like you can attack it in so many different ways and just as you said, like start with the why you know make it engaging.
Don't just drill it and kill it.
And I d I don't really understand why that's not more clear to people in the system, but perhaps they've just they grew up with that system.
It worked for them, you know, it just sort of weeds out other lines of thought or something.
I don't know.
It's a little surprising to me.
But I think the high school level is where you can have the biggest impact.
You get to c you know you get to the collegiate level and people have PhDs and there's a sense of this is the body of curriculum you need to know to be a computer science graduate, but the high school level it's all I mean that's a actually I'd love you know maybe you jump ahead.
So you you you've taught high school for many many years.
And one thing as an outsider I found interesting is hearing about well what would it take to teach computer science to every American 'cause that's right in Britain in Britain Carlton it's just like mandated as of a couple years ago and maybe in Spain.
Right, but
they're trying at least yeah
yeah yeah that's the goal.
The goal is that um a generation on com people are computer literate in a way that currently our developers are and the rest of the population kind of aren't.
Yeah well that at least for where I said that's not even on the spectrum of the American I mean not
not everyone's gonna be a compiler writer right but everyone's gonna be able to script you know something like Python or JavaScript to be able to script up a something or other that's that would that's the goal.
Right.
I'm gonna tee this up for Eric because I mean obviously you're the domain expert.
But what one thing I've been struck by is even if we had an um you know the perfect curriculum and even if we had a workforce of you know high school teacher salaried programmers who knew this stuff, there's still the issue of well we already have an existing curriculum.
It has to it does it count as an elective is it a science class?
In many states it doesn't even count as a science class.
So it has to count as an elective and while private schools and wealthy public schools have a bunch of electives a lot of traditional schools don't even have electives.
So there's just all these variables around if you had a magic wand, it's not enough to have the workforce and the curriculum and the hardware there's still all this political stuff that needs to get done just to cram it in because it's going to take the place of you know something else.
So anyways I tee that up to you with your decades of experience in the system.
You know you were gonna ask about um my experiences at PyCon and it's been pretty it was pretty funny to get into the programming world more seriously.
Mid 2000s I was uh doing some hobbyist programming projects as I'd always done um and I was using Java at the time and I had a friend who said you should try Python and this person was um not a programmer not a CS person um he's just another hobbyist and he the the line he said was your your programs will be about uh 30% as long as your Java programs about a third as long and so I was like okay I don't really
want to learn another language but I'll give it a try.
And so I had that classic experience of those mid-2000s of writing my first Python program and be like wow this looks really weird but it really is shorter and it looks beautiful and it works.
And I really haven't touched other languages much since unless it was a very specific project focused need for that.
And so what really brought me into more a more professional focus on programming to be really honest is my father died in 2011 and this is a month after my son was born.
And I live in Southeast Alaska and my parents had never been up here and they were about to to visit for the first time.
And I stand there with a smile on my face now because enough time has passed that I've processed that pretty well.
But my father being a programmer when he died um and I was with my mom uh that first week she asked me to go through his computer and see if there's anything worth keeping or to tell her about um and getting to go through his computer was a really hard experience but a really healing experience and connecting experience.
One of my takeaways was uh seeing all these projects that he was working on that would never see the light of day.
And so I realized that if I died that day you'd go through my computer and find all kinds of unfinished projects that nobody ever saw any benefit from.
And so that was a really transitional experience for me and it made me start to focus on rather than doing a bunch of little hobbyist projects which are totally fun because you're always starting a new project and not taking it to all the hard work of polishing and making it presentable for others I really started to prioritize you know having all these skills that I've picked up over decades of um having the opportunities to learn a variety of things what can I build that would be meaningful to other people what
can I build that would help others and so I started um looking at how to address problems in education.
And so that's what led me to PyCon because as a teacher at a small school um I got to go to conferences um and bring things back to our school and so when they said what what would you like to go to I said I actually like to go to a programming conference and see what I can pick up because most of us go to education conferences and so it's different to go to programming a programming conference and I was so intimidated because I thought a a programming conference would be a bunch of people who've spent their whole lives
programming and will look at me and say what have you done and that very first night at the hotel um waiting for PyCon to start the next day I just went down and had dinner and ended up in random conversations with Python people and found that wow half of the people are just like me.
They've done other things and they want to use programming to solve problems and half of the people are programmers first who are looking for what kind of problems they should use their programming skills to address.
I found that yeah PyCon was interesting in that it was m less pros than like DjangoCon.
Like DjangoCon's smaller but I guess if you're already at Django you're a little bit higher whereas PyCon I was also surprised it was a lot of people who were kind of interested in Python as opposed to professionally using it.
Sorry to interrupt.
Oh that's quite right you should interrupt me but that first year it was 2012 and Paul Graham from Hacker News was the the keynote and his uh focus was like 10 hard problems that people should solve and one of them was like university computer science and somebody got up at the end and said well what about high school computer science and he said don't touch um K-12 education is too hard and um that made me laugh but it also made me rage and say like these things can
be addressed.
So I think that when we when we talk about things like high school computer science curriculum in particular it is just a huge um I care trying to be careful about words is a huge mess of things to
Starts with cluster.
Yeah well it's a huge mess of of factors.
You have salary issues anybody who can do put together and implement a good CS program can probably go make two or three times as much money doing something else.
It's a lot of work to manage teaching and stay on top of current technologies.
Yeah and then you have to look whether you have political support within your school, within your school system, your state and then the country and so that that's a lot to untangle.
So were you teaching programming um at your high school when you went to the PyCon or y yet or not yet?
Yes.
Um I have been I was teaching for the last 15 years last yeah almost 20 years at a school of about thirty to forty students.
Um and so there's about ten thousand people in my town and I was teaching at a small alternative school.
And so um we had three teachers and so I would teach an intro programming class each fall if I could and I couldn't always justify fitting it into the curriculum.
But it was a really interesting chance to explore how you can teach computer science to people.
Yeah.
And it was always Python that when you were teaching?
Yes after you discovered Python?
I started that around 2008 um and so I had started using Python at that point.
And I I firmly believe Python is the best first language for people who don't necessarily want um a CS background.
Well you
you said before about um not focusing on the uh CS concepts but focusing on using the programming skills right and I think yo can you say more on that?
Because I think that that that's that's the gold juice, right?
Is if if you could learn to do all these things just pasting stuff together, then you can get the the fluency to take on the harder concepts.
Right.
So okay.
Um so where did Python crash course come from?
So I went back to PyCon in 2013.
So I spent a year just kind of taking in, like, wow, okay, I could really do something with programming.
Um I started working on some projects to address inefficiencies in education.
Um and there are a lot of them.
Still ongoing.
Yeah.
So uh 2013 I gave a lightning talk about um some of the ideas I had for how we could build some open tools to address problems and infrastructural problems in education.
And a good part of that was around the concept that in the 70s or so, um, computer scientists got together and said, we're gonna open source some things like text editors.
Like Emacs and Vim are 40 years old now.
Um and that's because I mean my take on that is people at the time said there are more interesting problems to compete on than building a good text editor.
And so people open source those and they've been maintained ever since.
And those are dedicated tools.
So if you're a programmer, you're in a text editor all day long, or IDE, um, and so you want an efficient tool.
And if you look at teachers and ask most teachers how do you build your lesson plans, they're still in Word documents.
And if they're not in Word documents, they're in some proprietary uh software that they're forced to use by their school or district.
And so when people move on, um all that work of their life's lesson plans is either mired in um thousands of Word documents that you cannot do anything with, um, or a proprietary system that they lose access to or uh becomes obsolete.
So I just gave a short pitch about um how we take we could take the open source principles and the two the true principles of um access and um right to modification and things like that, not just free, um, and build some some infrastructure.
And so I gotta I gotta cheer.
And it's so intimidating to give a lightning talk at a conference with 1,500 people and um everybody's looking at their phones and laptops.
And as a teacher, um having 1,500 people looking at phones and laptops while you're talking is really hard.
Uh but at one point I said something to the effect that proprietary software will never create a revolution in education.
And a bunch of people looked up and gave a little cheer.
Yeah, ding ding ding.
Yeah.
So Bill Pollack is the the owner of uh No Starge Press, and he was in the audience and he came up afterwards and um said something along the lines of my kid is bored in school um occasionally and um I hope you build what you're describing.
And if you want to write a book, here's my card.
And so I was not looking to write a book because um I wanted to build these these tools for education, but I went back to my classroom and I had been teaching programming and I had a a list on my wall in my classroom.
Um the title of that list was what's the least you need to know about edge uh about programming in order to do interesting projects.
And that list was the first half of Python Crash course.
Um and I had been trying to um give students resources where they wouldn't be depending on me to to guide them through um learning to program, because I recognize that you know many students can learn at their own pace.
Um, but all the resources like resources I could find around then, 2012-2013, they just made too many assumptions about what you already know.
Um things like how to use a computer, um how to find hidden files, uh how to set up a programming environment, any number of things.
There were just too many assumptions so that um even well, my students couldn't do it as independently as I'd hoped.
Um they got through it because I was there to teach them, but I recognized that they couldn't use these resources independently.
And so that's where the the um the core structure of Python Crash course came from, making no assumptions about what people know, uh, but also speaking to them as mature learners.
Because the other resource that was available back then were Python for kids kind of books.
One of the things I love about your book is the the structure, because I think about this a lot teaching, and specifically that most most books still, most Python books I I view it as what how do you teach someone their first language versus their third or fourth?
And when you teach someone their third or fourth, you say, Okay, we kn you understand there's basic data types, boom, let me dryly go through the list.
Here's variables, here's how you do functions, here's how you do classes.
And it's so tempting to teach it to a fellow programmer that way, because that's how you would when you're on language whatever.
But for that first language, like you and your book, you don't like you you just go to list right away, like you're not as dryly in that bucket of like, here's the data types, here's the data structures, which which I love and I I realize it's actually quite difficult to do when you know those things, because that's kind of probably how you learned it coming from Java.
Yet obviously you had the experience of years of teaching it to normal people where they don't give a toss about like what's a string.
I don't know what a string is.
Um so I love that you did that and I aspire to do similar things to not just be wedded to this is how it I I would teach it to an experienced person, but this is how it you know, Django.
How do you teach Django to someone who has never done web development?
A lot you know, a lot of times there's an assumption that historically they came from PHP, they come from something else, but a lot of people it's their first time.
So um anyway, so I love that your structure is that.
I think it's actually quite challenging to do that well.
Because there's questions about like when do functions come?
Do they come before lists?
Are they you know, um, so you I'm impressed by how you did that.
And I'm curious about the thought of how that developed, because I don't I know it wasn't an accident.
Yeah, yeah.
It uh ties back to Carlton's question about um, you know, what do we teach people?
Uh what what's gonna grab them?
Why do what do we want to show people who say, I want to learn programming, but I don't know that I want to be a computer scientist.
Um I look at why people want why would a uh high s random high school student want to learn programming if they don't know they want to be a programmer.
Um is to to do interesting things.
And so when I looked at what my students wanted to be able to do, it tended to come down to something to do with games.
Um people don't often think this, but a lot of students are interested in data at a high school age, um, because they're trying to sort out their lives.
And so things like how much money will I make from this job, um, what area of the country should I move to, or the world that's safe, uh, that has a good balance of of life, uh, if people are impacted by health issues, poverty issues, crime issues, um that information is really, really compelling.
So uh two so far are games, data science, and then the third is apps.
Everybody wants to build an app or know how they're built.
Um and so in the Python world that uh is Django and Will, I've appreciated your post around Flask or Django.
Um it's you know, I was told a bunch of people, you know, behind the scenes said you're brave to wade into those waters.
Yes, yes.
Um it needs to be waded into because there's a lot of assumptions on on uh those questions.
Um so you know, Python Crash Course, um I wanted to I've always wanted to take people from um an understanding of the fundamentals of programming to how do I make my own projects?
And so the guiding question for cra for Python Crash course was what's the least I need to know in order to do these projects.
So every time I had a question about should I present this um aspect of Python?
Should I teach lists?
Yes, because you need them for any interesting project you're gonna do.
Should I teach dictionaries?
Yes, because you need to know that.
Um should I teach generators?
No, because you can get away with lists for a long time.
Um so that that was the the cutting floor question for what to leave in, what to what to let fall to the floor.
Yeah, well I think it takes a certain amount of I mean cer uh expertise and confidence to leave stuff out.
Because especially as a programmer, there's always a sense of, well, I don't want to not cover this thing, but if you cover it sloppily, you lose the reader um or you're not curating it for them.
Because they can go read python.org if they're so inclined.
Right.
Right.
Yeah, the the classic, oh, you don't need a book because all the information is online.
Yes, if you can sort through it.
You can go to python.org, you can open up the Python tutorial.
That's not that's not a tutorial, right?
That's exactly Will's case.
You know, you already know two or three languages, you you know, you can read about the data type.
It's not it's not how to program, it's not how to use Python.
Well, and I always ask people who say like some some version of like such and such is easy, like everyone knows how to do da-da-da.
I'm like, go find a random person with a new computer and have them install Python.
I 99 out of 100, they're not gonna get all the way through.
Even if it's a Mac, even if they like between installing it properly, path, virtual environments, it's you know, so I think if peop people actually do that, they go, oh wow, like even that step, right?
'Cause there's so many things that like we as developers, like even my computer now, like I I am sort of like, Ugh, if I had to set up a new computer from scratch.
Like I had to set this up last year and I decided not to just port over all my old things, but to do it from scratch, it was just like it was two weeks for me with all these little things and but I think people for you just forget, right?
Unless you're dealing with a beginner all the time, y you just forget, you know, how b how bad it is.
Yeah, and I think a lot of programmers grew up around other programmers, whether it was within their family or in their community.
And so they didn't notice that when they were setting up their own computer for the first time, there were ten little things that they didn't know how to do, and there was somebody right next to them to say, Oh, just do this.
And so if you if you didn't struggle enough because somebody else took that struggle for you, you don't notice those blocks.
But even things like opening a command line.
Yes.
And it doesn't matter which command line it is, it's like, well, what is this?
Um, you know, everything you type is a syntax error and nothing works and there's no buttons to click.
And how do you learn that?
Like we did, but how do you do it?
It's getting harder because the um all the operating systems, um, or I shouldn't say all, um, Mac OS and Windows continually hide more and more of that.
And so um when I started teaching programming in the mid-2000s, even students who hadn't um done anything to do with programming knew what a file extension was.
And at some point they started hiding file extensions by default.
And so now you can tell somebody save a pile save a file as a dot pie file, and they have no idea what a dot extension um is.
And so you have to explain things like that if you don't want to lose people.
Yeah.
I I mean I used to make I still make the analogy of of an automatic versus a manual car, whereas computers are automatic cars, and if you go manual, you're using the command line, you're doing all these things.
Why would you do that?
You have it's harder, but you have a lot more control and it can be more performant.
Um but you know, who who knows what a manual car is anymore?
Right.
Um, but it's super satisfying.
People underestimate how much um learners, and I've said high school students a lot, but I've I I always have thought of people old enough to not want uh kid focused resources.
So when I say high school students, I'm including anybody from that age all the way up through uh people in their 20s, people mid-career, 30s, and 40s, and retired people.
Uh they all fit into that category of I want to learn programming, I don't have any kind of formal background in it, what do I do?
Uh one of the really satisfying aspects of um the last few years for me has been that Python Crash Course really worked for people from 10 years old to 90.
Um getting that continuous uh stream of email from people in all those different demographics has been super satisfying.
Yeah, that must be amazing.
Yes.
And I and I'm sure the I mean I as a question, what are some of the unexpected motivations of that age group um for why they would turn to programming?
Like what didn't you expect?
You've you've mentioned a whole bunch of ones, but
um well, let's bring this back to Django a little bit.
Um so you know, the structure.
Um writing is hard.
I thought I would write the book in one year.
It was two and a half years.
Uh I thought I would do a draft in the summer during vacation when my kid was two.
And then we're gonna go.
Yeah, revise it over the school year and it'd be done.
Uh, didn't get the draft written that first summer, and so writing turned into 4 30 uh uh getting up at 4 30, writing for a couple hours, uh going teaching, doing family stuff, and then picking it back up at 9 30 or 10 at night.
Um so that was long.
But um the book is also two books in one.
So the first half is a classic introduction to programming, um, what are variables, data structures, functions, classes, and I included um testing, because I did not learn about testing software probably until like 10 or 20 years into my hobbyist career.
And as soon as I learned it, I was like, why didn't somebody show me this a long time ago?
Um so th that kind of thinking, what do I wish I had learned um as an as an early programmer guided some of my thinking on what to include.
Um but another piece of this is a reaction to seeing the way computer science is um introduced in schools.
And many times it's introduced as here's this cool project, here's a game, it's a working game, now here's the code for the game, now modify this little part of the code, and look, you have changed the way this character behaves.
And people love that and it's great.
Um, but that just motivates you to learn.
Um and so I uh with a book in particular, um I take it as people want to do projects, but they also want to be in control of their projects.
So if you g give them a foundation in how programming works and trust them to have um the discipline to get through that, if you teach them well, then when they get to their projects, they're gonna be able to run with it.
Um and so that's been satisfying as well.
And that that brings me back to Django.
So J Will has a great question.
How do you teach somebody um who doesn't have any background in programming how to jump into Django?
Um I think one of the reasons that Python Crash Course has done as well as it has is because I take people who have never um done anything with programming, um, give them a a meaningful introduction to the language and programming in general, um, and then they build a web app and deploy it, and their friends all over the world can use it.
And that's a pretty impressive um accomplishment.
Um and it's why I'm happy for people who are just learning to program today.
Um, you know, I made a number guessing game on my dad's unfinished computer um on Pol uh computer in a basement in the 70s, and that was cool, but there's no way anybody else could have played that.
And now you can do a project like that, um, put it behind a Django app, um, deploy it, and anybody in the world can use it.
And so when we talk about satisfaction of building something, building an early project, even if you're doing a lot of following the um the steps that somebody else wrote out, which you have to do for your first Django project, the fact that something that you have built has worked all the way through deploying um is incredibly satisfying.
And my hope is for people to go through that process and then step back and kind of look at the parts and say, all right, there's a list, all right, there's a dictionary, all right, there's a piece I have no idea what it's doing.
And when people get to those questions, they say go read Will's books.
Yeah.
Thank you.
Well you cover quite a lot in just the the Django project.
I mean, you you cover environment variables, um which is something that actually I don't I mentioned, but I don't cover until the professionals book.
Um so it's it's a fairly it's pretty robust the learning what it's learn learning library.
Is that the one?
Learning log, yes.
Learning log, okay um Yeah, it's I mean, but I I I'm biased.
Of course I agree.
Like I mean you're providing the context for someone.
I mean that's kind of with my uh Django for Beginners book, there's you've built five projects in the first couple I'm explicitly telling you what's happening, but saying, you know, you're it's not gonna click for you until the third or fourth time.
But I'm gonna but you need to get it working, and then again you have that context, and then you can see, oh maybe I want to learn like I've used models, but what is how exactly is that?
And you know, what's the view?
Um, but you're kind of providing that context that someone who hasn't is isn't new to or someone who was new to well web development hasn't uh doesn't have.
Um so I do think there's some degree of like it's fine to blindly follow for a while.
Rather than you know, and and and I was in I was uh motivated or influenced by the the Rails tutorial, which when I was learning Django in 2012, 13 I I wasn't able to find really beginner-friendly resources.
Right.
And yet Rails had the Rails tutorial, um uh was it Michael Hartle?
Hartle, I think his name right.
Um, and the very first thing is boom hello world and deploy it, and it helped that Heroku was built for Rails initially, um, but it was just like boom, here you go.
And so that's that's what you do in my book.
The first app is hello world and you deploy it, and as you said, then you can share it.
And I almost when I teach in person, I I all I always say, here, add the Google Analytics code, just copy and paste this, send it to four friends, and guess what?
You can spy on them and find out if they actually looked at it, and then people's mind explodes, right?
In the same way that like I I show people teaching them HTML, I show 'em um how to deface the New York Times, like write a message, right?
People's mind explodes, right?
Yeah, it's like, oh, you know, there's a server and there's a client.
Like that's a great, you know, so the same thing, when they can actually track it, you can see the the gears going, they're like, oh my god.
So it yeah.
I I I agree with that approach.
Yeah, I mean a fun question for me is uh, and this is all it comes back to power.
All right, why did I why did I go into education if I got a BS in physics?
Um I graduated in '94 with BS in physics and I wanted to be a particle physicist.
Um I was on this quest to understand the universe.
Um and but I didn't want to be a student forever.
I didn't want to wake up and be 30 and still be a student.
And so I uh took a couple years off of
Carlton as you say that.
How many how many years were you getting that PhD?
A few, a few.
Yeah.
That's right.
I did I did master's everything but project later on, so um
what's it, A B D, all but dissertation, right?
That's the next step.
Yes.
Um But I went to teaching for a couple years.
Uh taught in New York City for I committed to teaching for for two years and then found that I loved it.
I found that the the challenge, the intellectual challenge of trying to teach every kid in a classroom, trying to reach every kid, was as hard as anything I had found in science.
Um it's pretty easy to stand up and present something and okay, the kids who get it, great.
Um, but if you take it as your responsibility to find a way to reach every student, wherever they are intellectually, academically, and in their their own lives at home, um that is hard.
And I'm not sure that you can reach every kid, uh, but the pursuit of that is as as satisfying as anything I ever found in science.
Um and then sharing, well, what I love about science and and math is it's an attempt to understand the world.
And so helping other people understand the world is incredibly satisfying.
So that's what kept me in teaching.
And so I I think of teaching as sharing power, so sharing understanding and sharing power.
If you understand the world, um people can take less advantage of you and you can do more to control your world and the world of people around you.
And so when we think about technology and things like apps, um, you guys are well familiar with the idea that the people who build um the tools that we use, the apps that we use every day, have power over our lives.
And so for me with Django, the magic of Django is um if you can teach people Python in a reasonably efficient use of their time and then teach them how to build a web app, um if they never touch code again, they have such a clear understanding of um how the technological tools that they're using every day are built.
And I like to think of pulling the curtain away.
Uh it seems like magic when people are not programmers and they use all these apps.
Um, why can't Twitter do more to control abuse?
Why can't social media do more to fight disinformation?
Well, they can.
It's a lot of political choices and economic choices about um how to.
But when you've written code um that has some if statements in um a Django app, you have a sense of how those people might approach that.
Uh and then if you want to build that, um you can.
So one of the joys about going to PyCon is half the talks are technical and half the talks are what happens when people who have this new power start to address the problems in their lives.
No, I mean, and that for me, that that that power to make changes, that that that's one of the things about that makes being a software developer exciting, is that you can write and you can build things.
It's one of the things that you know I try and communicate to other people.
This is what programming is all about.
It's shaping the world, you know.
Yeah.
Well, I love how you talk about math and science in terms of understanding the world because I often from the I I have a liberal arts background and I often like the idea of it's understanding people.
So you can say, okay, history is what happened.
Politics, you know, pol politic, government is well, what were the institutions doing to control it?
Economics is well, how did the money imp impact?
And literature is well, what was kind of the psychology of people at the time.
So you can come at the same events or situations from all these different lenses in the same way that in the sciences, you know, there's like the math, there's the physics, there's the chemistry, biology, they all intersect.
And so if you have the holistic idea of trying to tackle the same thing, but just a different angle, it's uh helpful to me in terms of I never thought of it quite as much in terms of the sciences coming together, but definitely with terms of the the arts side.
And philosophy, of course, Carlton as well, is another way of tackling the same issues.
Um you know, I I must say, Carlton, I mean, I just uh just as an aside, like I loved philosophy the first couple courses I took, but it felt to me like you were arguing without any content to deal with.
And why I was a history major is because I was like, well, you're doing all these things, but there's actually like what actually happened, right?
It's not just abstract.
That was what lost me with the question.
Okay, if we yeah, no, I mean there's the but this Plato discusses this.
What's the difference between the philosopher and the sophist, right?
The sophist uses the rhetorical tools, uses the arguments for the sake of argument for making the rook the weaker argument look the stronger.
It's a game, it's it's it's not a quest for truth, whereas the philosopher is the quest for truth.
And the the difficulty is you they look like academic debates, they look they can be dry and they can lose their connection to the world.
But you know, philosophy itself is is that deeper quest.
Fair enough.
Um Eric, you've already sort of answered that.
No, I know I'd I we'll see.
Um you've already uh indirectly answered this, but one question that I'm asked all the time that I'm gonna throw to you is how much Python and what Python do I need to really understand before I should dive into Django and web apps?
Oh, first half of Python crash course.
Yeah, exactly.
Um, that's that's a good question, and um I think that's a really important question to ask.
Um I've I've had a hard time with that question when I've when it's asked outside of the context of my book, because um I've never liked to feel like I'm plugging my book.
Um but that was uh my guiding question in figuring out what to include in the first half of that of Python Crash course.
Um because one of my goals was to get people ready for a game project, ready for data science analysis and visualizations, and ready for a Django project.
And I think if you ask that same question of how much people need to know for building games, how much do they need to know for doing introductory data analysis and visualization and Django or Flask or any number of web apps, I think you need to know what a variable is.
Um this idea that it it's a reference to information, points to information.
Um you need to know how about collections, uh you need to know about lists, you need to know about loops, iterations, um, you need to know about dictionaries, because dictionaries are the idea of mapping two pieces of information, connecting bits of information.
Um you certainly need to know about functions, um, and you need you need a passing, uh I should I should say, introductory level of understanding of classes.
I think a mistake with that people make in thinking about learning classes in object-oriented programming is they think they're gonna have to write a bunch of classes, and a lot of times the real value in learning about classes in object-oriented programming is you're probably not gonna write too many classes yourself, but you're gonna use classes that other people have created.
So understanding that a class um is a representation of a kind of a thing or a concept, and then an object is an instance of that, an example of that, a specific element of that, of that kind, um is important.
I struggled that with that for a long time because I didn't learn object-oriented programming.
Um I remember going to my dad and saying, like, what is this?
I've been hearing about this for years, I've always avoided it.
Um and he said the classic uh it's just a thing that allows you to combine information and actions.
And I think that's still pretty relevant and it simplifies it, but uh, it's the big point.
Uh class is a a way you can store information and define actions together.
Um you can represent real-world things and you can represent abstract concepts.
Um so that's that's just I'd throw one more thing in there, and that's dealing with files and exceptions.
Um I like those together because what happens if you open a file that doesn't exist if you try to?
And just that word try, oh, there's a try Python word.
Um that's important.
And I also throw testing in there.
And you can make an argument that people don't need to learn about testing right away, uh, but it doesn't take much to throw the concept of testing your code um in for somebody who has learned all that so far.
And I think it's really important to to put that in front of people um so that as they do start to get into meaningful projects, they're aware that, oh, I should start testing my code at some point.
I have some idea how to do that, and it's not this big giant new thing that they have to to deal with learning at some point.
Yes, yes, yes, yes.
I mean, testing, I completely agree.
I mean, in the in my uh beginner's book, I introduce testing.
I kind of just give it to people.
I mean, I I actually a separate thing, I want to do a whole course on testing, but I do say here kind of it is.
I'm gonna broadly describe it, but like you should have it and it can run just to get it in their mind.
Right.
Um, but I do think what you're saying about classes and and object-oriented, to me, that's the piece that you need to actually like truly understand that uh at with it with Python before Django makes sense.
Because what what are class-based views?
What are mix-ins?
Right.
I mean, personally, I'm an advocate of class-based views over function-based views.
I mean, the source code uses it, but I you should do both, but I I often think of it as oh, okay, you can disagree with me.
I often say like you start with generic class-based views, and I still, like, as a in my own projects, if I can use that, um, shove things into there, I'll do that.
If I have to, I'll go to class-based, um, you know, function-based, and in so in terms of the learning, you start with those that just works.
If you want to modify it, uh, then you gotta go to classy class-based views.
It's a little scary.
Maybe you rewrite them from scratch as a function-based view, and then you come back around to, well, I'll just rely on the work of others and I'll modify that you know one little bit um and have cleaner code.
So you kind of need to cover all of it.
But you were making a reaction to my emphasizing class-based views.
No, I I this is like uh the flask versus Django.
Um please convince me otherwise.
I mean, I I want to hear more arguments for function-based views, because to me it's I think you do need I I think of it more as the the order in which someone should should have the because the idea is uh a programmer would say, Well, I like a function-based view because it's all there in front of me and I don't want magic.
And I would say, Well, everything is magic to a beginner, so I'm gonna give it to them in two lines rather than ten, and then I'll backfill it later after they've learned how to do a list view, a detail view, a template view.
Well, then we'll do it from scratch.
That's what I would say.
Yeah, I okay.
I have always thought of teaching programming first and teaching Python second.
Um so every year I look around at the the language landscape and ask myself if I should still be teaching Python or if there's something better to work with and teach.
Um I do the same with Django and other frameworks, and I do the same with um aspects of Django like uh function-based views or class-based views.
Um in my project, where it's the last project in the book, and it's the last thing that people are gonna walk away with from this specific book.
Um, there's so much magic already in the Django project that I look for um what are aspects of this project that people are gonna really understand and start to work with.
Um and I think from what I've seen so far, function-based views are are a little clearer for people to think about.
Here's the function that takes something in.
The request uh parameter is the probably the the most magical thing in there.
Um but as far as people writing um their queries, and they're just simple queries in these first projects, um, and then calling another function that that renders the the um page.
Um I I like how clear that progression is.
Um And if I see a clear argument that says everybody's gonna be using class-based views all the time from now on, I would not keep I would switch over to class-based views.
Uh but seeing that people are still using function-based views.
Who's who are those people?
Well, I think if you're teaching the web problem though, right?
The web pro the function-based view approach is great.
You to you you're turning requests into responses.
And so you see the requests come in and you return response.
And that's the web problem.
And the class-based views totally hide that.
And until you go right into the and you say, Oh, it's just actually a function-based view, but you know, it's wrapped up in this stuff.
And it's but I think if you if you're teaching the web problem and that's the introduction, it's got to be the clearest way.
And then, okay, when do class-based views come in for me?
They come in when as soon as you're doing create views or update views or delete views, use the generics because you know they're a bit weird and you have to open classy class-based views to remember what the parameters are and all the rest of it.
But they just save you loads of typing.
But I think Will has a different use case and a different audience.
And so, what's a good writing principle?
Know your audience.
And so I'm choosing function-based views because it's the last project and it's the last thing, last chance I have to work with people in this book.
And Will, you're you're doing that as the foundation for okay, here's the first uh couple projects I'm gonna show you, and then we're gonna dig deeper into all of this.
And so I think that that your rationale is pretty good.
Yeah, well, it's it's true that I tried to say you don't have to know much Python to get through my beginner's book.
Um, so I but I yeah, I it does make me think about the to Carlton's point about the parallels between the requests.
Um yeah, it's something I think about.
I mean, actually uh uh something this morning I was working on is I've played around with it and I'll probably hopefully I'll have this post out by the time this interview comes out of the idea of how many ways to do in a uh a home page or a simple page in Django.
Because I think this is something that is um really interesting once you're at an intermediate level to understand all the mutations.
But it's completely confusing and non non-helpful to a beginner.
So when I show someone how to do hello world, I say, which you know, take as a homepage, I say, okay, we'll we're gonna create a uh an app, let's call it pages, we'll have a template, we'll use template view, and we'll have a URLs.
Good.
But you know, you can cram it all into the project level URLs.py file.
You can use a string instead of a template, you can um use a function view, you can use a class-based view.
Uh, you know, you can go to the extreme.
Carlton has this wonderful talk about how simple can you make Django to make it, I forget how many lines of code that is.
We'll link to that.
You gave a talk and we have a post on it, you know, where you make it flask-like.
So I find that that's in terms of again, I always think of like what's the order in which I present things to someone?
Because I I'm not trying to prove to them that I know this.
Like hopefully I know it.
It's what's the progression given that everything is magic, everything is abstraction.
How do I find that mix between context so they understand what's happening, they have a why, and the harder work of learning the fundamentals within that?
So that's I don't know if that resonates with you, but I th I can think of like I think six different ways to do that that home page, and each one sheds a light on a different nuance around Django, because I often think of its batteries included, ha it has guardrails, but really you can do whatever you want.
Like an apps are just like a nicety.
Um but once you start breaking those things down, right?
If I showed that to a beginner and I've done this, they're just like their head explodes, you know.
Um, because usually for a beginner, what I want to get across to them is I want them to understand the interaction between models, views, templates, and URLs.
To me, that is the single biggest thing to get over for a beginner because it doesn't matter the linear progression of which you write them, you kind of need all four.
And you just need a to me, a bunch of reps before that clicks.
But once that clicks, then it unlocks, you know, what is middleware and and so at least as I teach Django now, that's how I view it is I want to get someone over that hump.
And the way I get them is kind of follow me and then I'll fill in the, you know, the the details as we go.
Well, I think that's a good approach.
I mean, you're well, I go back to um your goal as to have people get something up and running that works, and then you're gonna start to dissect that.
And so I think for you having fewer lines of code and more magic uh at the beginning is totally appropriate, uh, as long as you do um take people through a thoughtful dissection of what was working so they know what they need to understand, and there's some things to leave as magic.
Um, you know, we cannot I I I wanted to throw this point in.
Um I just still shake my head and marvel at any um notion of dismissing web developers as not real programmers.
I don't understand where that comes from unless there are people who just have written so many crud pages that that's what they think all of web development is.
There is so much going on in a web development stack.
Um and then you even can ask the question of like what is this particular project addressing?
So if it's a science-based site, if it's a business site, any number of things, not many people can understand truly everything that's happening in that stack.
And so there's so much room for us to be learning all the time.
And so I think most, maybe even all of us, need to leave some things as magic or things that other people have sorted out and I could dig into someday if I need to, but I won't until I need to.
And I think that's totally appropriate.
And I think it leaves you uh the space to work on the real world projects that most of us care to work on.
Yeah, I think that's the key to not feeling overwhelmed is to understand that you don't have to master everything right now.
It'll, you know, programming's fractal.
And on top of that, I mean the reason why I like web development is I think it's it is a liberal art.
There's there's so many, so much nuance to it.
I mean, front end, back end, HTML.
I mean, it's just endless the number of things you can poke around in.
Um maybe a little harder in a professional context, but certainly for hobbies and side things, it's just never ending.
Um, which because I I get you know, I get stale if it's I always how can you teach calculus at the collegiate level, right?
It's four five hundred years old and it's the same thing you're teaching for 30 years.
Like, I find like to me that's the inspiring thing is someone who can make who can get motivated and interested about that.
Whereas the web is just like, well, it changes all the time.
So I'd love to be bored maybe a little more than I am.
You know, we're probably getting towards the end of this.
Uh so um I think a good way to wrap this up is to um kind of remind people, reassure people, since we've been talking so much on learning how to use Django and uh learning Python, um, our goal, I think we probably share this goal, is to make people not need us.
And so at some point, I think you know, people read my book, they read your books, they um go through some learning resources, but at some point, if you stay with us, you get to a point where you learn all this just from reading the documentation.
And you still post questions of Stack Overflow and you still ask questions of your your colleagues and peers.
Um, but you become proficient enough that you can dig into the internals, uh, dig into the Django code, um, look at other projects and see how they do it.
Um And so we like people to buy our books and read our books and we enjoy watching them progress.
But I think our goal is is a shared goal of having people not need us and get to that place where where they can um sort things out for themselves and be confident in doing that.
Carlton, I thought of you last night I was literally to the to reading the docs.
I I I always try to think of what does it feel like to sort of kind of know Django?
How do I impart that to someone?
And I view it as I have a sense of the spider, the tapestry, but I don't have everything, I don't know everything.
And so I was looking at um, so why do you use manage.py versus Django admin?
Because I just sort of blindly, you know, I know Django admin I use with start project and manage.py with run server, and and I know Carlton knows the answer to this, but I never really thought about it.
I was like, oh yeah, like I was reading something and they were like, I was like, oh yeah.
And I go to the docs and it's like, oh well, you know, if you use manage.py, it loads in your your your settings module.
Um and to me, again, I that's that's exactly your point of like even though I've been using it, like I went and read the docs, and A, I found it interesting, and B, I found it helpful.
Um and you know, I could read the docs till infinity and still learn stuff every time.
So um and of course I was like, I know, I know Carlton knows that.
So I've got in front of me, I've got um a document browser open.
I've got one, two, three, four, five, six, seven, eight, nine.
Nine open tabs for the stuff I've been working on before the podcast here, right?
I have the docs open forever, all the time.
Um and there's that's not this there's not this idea that you get to the point where you don't need the docs or you don't need the source code.
No, it's more and more and more.
Yeah, it's just the resources you use change.
Um Well, we are out of time.
Um we have links to everything.
We didn't even get a chance to talk about your Python flashcards.
Uh are there any uh concluding thoughts or would you like Django people to reach out to you?
What how do you want to end this?
Yeah, I'm always available.
I think the easiest place is Twitter at eH Mathis, and my email is not hard to find.
I think one closing thought is um if people are looking for any of these books, my books, your books, anybody's, um one thing I get repeatedly is people who accidentally buy early editions uh because the thing beginners don't always know to look for the latest edition of a technical book.
Uh so if people are following up on any of these resources, uh make sure you're you're finding the latest edition.
That would be the second edition of your book.
Yes.
Great.
Well, thank you so much for coming on.
Wanted to do this for a long time, uh, and I think it'll be really interesting to everyone.
Thank you.
Absolutely.
All right, thank you for having me.
All right, everyone, we're at Chat Django on Twitter, DjangoChat.com.
We'll see you all next week.
Bye bye.
Join us next time.