Learn Python with Talk Python's 270 hours of courses

#149: 4 Python Web Frameworks, Compared Transcript

Recorded on Tuesday, Jan 30, 2018.

00:00 Are you considering getting into web programming?

00:01 Choosing a web framework like Pyramid Flask or Django can be daunting.

00:05 It would be great to see them all build out the same application and compare the results side by side.

00:10 That's why when I heard what Nicholas Hunt Walker was up to, I had to have him on the podcast.

00:15 He and I chatted about four web frameworks compared.

00:18 He built a data-driven web app with Flask, Tornado, Pyramid, and Django,

00:22 and then put it all together in a presentation.

00:24 We're going to dive into that right now.

00:26 This is Talk Python to Me, episode 149, recorded January 30th, 2018.

00:32 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.

00:52 This is your host, Michael Kennedy.

00:54 Follow me on Twitter, where I'm @mkennedy.

00:56 Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.

01:03 Talk Python to Me is partially supported by our training courses.

01:06 How does your team keep their Python skills sharp?

01:09 How do you make sure new hires get started fast and learn the Pythonic way?

01:14 If the answer is a series of boring videos that don't inspire or a subscription service you pay way too much for and use way too little, listen up.

01:22 At Talk Python Training, we have enterprise tiers for all of our courses.

01:26 Get just the one course you need for your team with full reporting and monitoring.

01:31 Or ditch that unused subscription for our course bundles, which include all the courses, and you pay about the same price as a subscription once.

01:38 For details, visit training. talkpython.fm/business or just email sales at talkpython.fm.

01:47 Nick, welcome to Talk Python.

01:48 Hey, thanks for having me.

01:49 Yeah, it's great to be here.

01:50 It was really nice to meet you last week at PyCascades.

01:53 That was a fun conference.

01:54 Oh, man, that was awesome.

01:55 That was my second Python conference ever, and it was on par for me with PyCon.

02:01 Yeah, it was definitely a different vibe.

02:02 It wasn't like a huge expo hall or things like that, but I felt it made up for it in the richness of conversations.

02:10 You could sit and talk with three or four people, and those people were amazing.

02:13 Right, and the one thing that's been different is I've done a lot of academic conferences.

02:16 I used to do astronomy, so I've been to a few national conferences, and I've always missed out on talks.

02:21 And this is the first conference that I've gone to where I had the actual opportunity to sit and hear every talk.

02:27 I didn't feel like I missed out on anything.

02:29 Yeah, and the talks were really good.

02:30 So congrats to everyone.

02:31 That's a new conference, and you missed it this year, but it's coming to Seattle next year and then Portland the year after.

02:37 And it's supposed to kind of go up and down the Cascades and the West Coast of the U.S., the mountain range.

02:41 So it should be a lot of fun.

02:42 I'm looking forward to going next year already.

02:45 But that's not what we're here to talk about exactly, although we are going to cover a talk that you gave there, which sort of surveys a bunch of the popular web frameworks.

02:53 And we'll get into that.

02:54 So let's start with your story.

02:55 How did you get into programming in Python?

02:57 Sure.

02:57 I actually didn't think I'd ever be programming, ever.

03:01 I started doing astronomy back in about 2007.

03:05 I just got really interested in how stars lived and died.

03:08 And so I started doing astronomy.

03:10 I started doing science.

03:10 It seems like one of the most amazing parts of all science is astronomy these days.

03:15 Yeah.

03:16 I mean, there's a lot going on in astronomy.

03:18 A lot of my former colleagues are doing some amazing work finding planets, learning about black holes that we didn't know existed, all kinds of great things.

03:25 When I started doing astronomy, I naively thought that I would just be looking through telescopes and taking down notes and thinking through equations and that kind of thing.

03:33 I didn't think I'd be writing any programs at all.

03:36 And so when I got into grad school, even before I got into grad school, I had to learn how to program a little bit.

03:41 And I used Fortran 77.

03:43 And that was, I hated it.

03:46 I hated it.

03:46 I hated it.

03:47 I did, too.

03:48 I had to take it.

03:49 I was in engineering at first.

03:50 And they told me, I said, can I please take C++?

03:52 They said, no, you have to take Fortran.

03:54 It's the most important language you'll ever learn.

03:56 I'm like, no.

03:58 Well, it's one of those things where, like, when you're in academia and you're an undergrad or you're in grad school, you learn the language that your advisor knows.

04:07 And my advisor knew Fortran, so I learned Fortran.

04:10 And then when I went, that was at Columbia.

04:13 I was in the Bridge to the PhD program there.

04:14 It's a great program for the scientists.

04:16 And when I transferred into a graduate program at the University of Washington, then my advisor was using a language called IDL.

04:26 I forget what it even stands for, but it's a proprietary language.

04:28 So you have to have a license on your computer to use it.

04:30 And if you wanted to be able to, like, do work at home, you have to have a license on your home computer to use it.

04:35 And so it's a whole lot of stuff with that.

04:37 You have to be connected to the internet so they can verify your license.

04:40 Oh, it's that intense?

04:41 It has, like, almost like a dongle type thing?

04:43 No, it's not a dongle.

04:44 It's more like if you're not connected to the internet, then you can't use the IDL editor.

04:49 Wow, that's intense.

04:50 And you can't run your IDL program.

04:51 That's kind of the opposite of it.

04:53 Which sucks.

04:53 Yeah, it's terrible.

04:55 Exactly, exactly.

04:56 And so I actually learned Python partially to get away from IDL.

05:00 It was kind of my way out.

05:02 I was like, I had been introduced to this language, and I was like, oh, this is a free thing.

05:06 I don't have to have a separate license to do this.

05:08 I can install it on any machine.

05:10 It looks like English.

05:11 Like, this is...

05:12 Yeah, yeah.

05:13 Why not?

05:13 Yeah, absolutely.

05:14 So I used Python for my research.

05:16 I used Python for my homework.

05:17 And then one of my colleagues at the time, like, and this is kind of where it really took off for me.

05:22 He had been doing blog posts about science.

05:25 And I was like, oh, that sounds cool.

05:26 I should do that too.

05:28 And I used Python to help me learn more about the science that I was doing.

05:33 And I was using the science to help me learn more about the Python that I was writing.

05:36 And so I kind of got a lot of that practice, you know, after hours, just using Python to answer interesting questions.

05:43 Yeah, that sounds really cool.

05:44 It's a very organic story of just like, I kind of just found my way into it.

05:48 And I just, you know, I sort of grew as you played with it.

05:51 That's awesome.

05:52 So like I said, I'm a big fan of astronomy.

05:54 Are you still doing that today?

05:55 You're not, right?

05:56 You're sort of...

05:57 I'm not.

05:57 You took the path that I did.

05:59 Like, let me work on a PhD and actually do nothing and just go programming with it later.

06:03 Now I just feel bad.

06:04 But yeah.

06:05 No, I know I do too.

06:06 I kind of looked at my advisors and stuff when I left.

06:09 I'm like, yeah, I'm sorry, but I'm going.

06:11 It was tough, actually.

06:13 But I think it's totally the right choice for me.

06:16 I don't know about you.

06:17 Yeah, it was time.

06:18 I wouldn't make a second choice in a second.

06:20 You know, I met some great people there, but I'm much happier doing what I'm doing now.

06:26 Yeah.

06:26 I feel like the PC experience in all of grad school kind of taught me how to do what I do now.

06:31 But I feel like I'm applying it in a place that makes a bigger difference for more people.

06:35 Right.

06:35 I'm still doing as much reading as I was doing during my PhD program.

06:39 I'm still doing as much thinking, but it's toward...

06:42 So one of the problems that I had with the work that I was doing in my PhD program was

06:45 it was not very easy to explain to other people why it was interesting or important.

06:50 I knew why it was interesting or important.

06:51 I love like aged stars and seeing how like what was happening as they were dying.

06:55 But in order to explain that, I've got to explain, okay, look, this is how stars evolve.

06:59 This is what all this stuff means.

07:01 I've got to apply all this background.

07:03 Whereas, you know, what I'm doing right now, I'm teaching at Code Fellows.

07:07 And I can just say, you know, I'm teaching people how to program, you know, teaching people how to make websites.

07:11 So, you know, the kind of stuff you see like a Google.com or anything.com, I'm teaching people to do that, at least at the basic level so they can go out into the real world and get a job and do that stuff for real.

07:22 Yeah.

07:23 And it's a great experience to help people sort of change careers or advance their career down some other path they weren't doing before.

07:30 So what is a typical day?

07:32 So Code Fellows is a boot camp for those who don't know, right?

07:35 And what's a typical day there look like?

07:37 Yeah.

07:37 Code Fellows is one of the coding schools in Seattle.

07:40 I'm a little biased.

07:41 I think it's one of the best ones.

07:42 But I also work here and I know some really good people.

07:45 But a typical day when I'm teaching looks like three hours of lecture.

07:49 Let's say I'm teaching one of my Python lectures.

07:52 It's like, okay, we do about an hour of code review.

07:55 And then we talk about some topics.

07:56 We do some data structures.

07:58 We do some algorithms practice.

07:59 I'll teach you about a web framework or some aspects of a web framework, like what a model is or what a view is or how to do routing or security, that kind of thing.

08:09 And then we go to lunch.

08:11 And afterward, they come back and they work with each other on lab assignments.

08:15 And we build the lab assignments to complement the lectures.

08:18 And so I teach a thing.

08:19 And then they use that concept in their application.

08:23 And after that point in time, they're kind of on their own.

08:26 They're still on location.

08:28 But they're on their own building the projects.

08:31 And myself and the TAs are here to grade their assignments and to be resources when they need help.

08:36 Yeah, that sounds like a really fun job.

08:38 And how long does the boot camp run for?

08:39 The full sequence.

08:40 So there's three levels to it.

08:42 201, 301, and 401.

08:43 201 is four weeks.

08:45 And that's the basics of HTML, CSS, and JavaScript.

08:48 And then the 301 is also four weeks.

08:50 Because you have to do that.

08:51 There's no way to avoid JavaScript.

08:53 Right.

08:53 Like there's no way to avoid it.

08:54 That is the language of the web.

08:56 Let's be honest here.

08:57 Yep.

08:57 It is.

08:58 So 301 is also four weeks.

08:59 That's more intermediate.

09:00 HTML, CSS, and JavaScript.

09:01 We talk about jQuery.

09:02 We talk about more libraries.

09:04 We kind of get people kind of more interested in the wider scope of being a web developer.

09:09 We start dipping into the back end a little bit with Express, but not too much.

09:13 And then in the 401, that's 10 weeks.

09:15 We have several 401s.

09:17 We have Python.

09:18 We have JavaScript.

09:19 We have Java.

09:20 We have C Sharp.net.

09:22 And that's 10 weeks.

09:23 For the Python class, that's basics of Python, a preliminary web framework like Pyramid,

09:30 and then a more advanced web framework like Django.

09:32 This is actually where my talk came from because I've been teaching this course or at least

09:36 being a part of the teaching process in some way, shape, or form for the last almost two

09:40 years and having all this exposure to it.

09:43 And I was like, huh, I wonder what these other frameworks look like because I'd only ever

09:46 taught.

09:46 I'd never actually learned Python for web development in my graduate work.

09:50 I was doing astronomy.

09:51 I was doing data analysis.

09:52 I only learned how to do this stuff on the job.

09:54 They don't have web frameworks for machine learning across.

10:00 You don't build web apps, right?

10:02 You do build other stuff.

10:03 Yeah, it's all custom software.

10:05 Yeah, exactly.

10:05 I'd never actually used Python for web development.

10:07 So I only learned this stuff when I was on the job.

10:10 And so I'd only been exposed to Pyramid and Django.

10:14 I did a little bit of Flask just kind of as a one-off thing, but I didn't really understand

10:18 what I was doing.

10:19 So I didn't really take the time to get to dig into these web frameworks.

10:22 I was like, okay, I wonder what these other ones are like.

10:26 I should try to talk about that because I'm sure I'm not the only one who thinks this.

10:29 No, I think it's a super interesting idea because a lot of times what I find is people,

10:34 they kind of do a quick survey.

10:36 They're like, all right, what's out there?

10:37 Django.

10:38 Okay, there's a lot of building blocks already built.

10:39 They're kind of big.

10:40 And I like, okay, well, there's a micro frameworks and they're really small.

10:43 I put pieces together.

10:44 This one or that one is mine.

10:45 That's my style.

10:46 I'm going to do it.

10:46 And then they kind of just stop, right?

10:48 You learn what you need to know to do the job you try to do.

10:51 Yeah.

10:51 And most people aren't doing, unless you're a contractor, you're not doing a new project

10:56 every three months.

10:57 In a different framework.

10:58 Right.

10:58 In a different framework or a different language entirely.

11:01 You have your job.

11:02 You might jump around from company to company, but you still like, most places are hiring for

11:08 Django, so you learn Django.

11:09 Or they're hiring for Flask, so you learn Flask.

11:10 Or you're just building tools for the backend.

11:13 But yeah, in my 10-week class, it's all that plus data structures and algorithms and a little

11:21 smattering of machine learning.

11:22 So it's like end to end with the week breaking between each class, it's about 20 weeks total.

11:26 Wow.

11:27 It sounds really fun.

11:28 It's something like I could actually kind of enjoy hanging out there and just being part

11:32 of that.

11:32 That sounds fun.

11:32 It's great.

11:33 It's super intense.

11:34 And honestly, now that I've taught it, I really wish that I had learned to program this way.

11:39 It's really directed.

11:41 When you go through undergrad and you get your degree, you've got to do a lot of ancillary

11:46 stuff, which is great for building a well-rounded person.

11:49 But if you're focused on just wanting to do one thing, it tends to get distracting.

11:53 Whereas with this, the goal is clear.

11:57 We want you to get a job.

11:58 So we're going to train you to be able to do the things that jobs are asking you to do.

12:03 And that's it.

12:04 There's no humanities requirements.

12:06 There's no other paths here.

12:08 It's just like you're here for a specific reason.

12:10 If your cause doesn't fit that reason, then you want to go somewhere else.

12:14 But it's directed.

12:15 It's focused.

12:16 And it's cheaper than an undergraduate degree by far.

12:20 Yeah.

12:21 By quite a bit.

12:22 Yeah.

12:22 And time and money.

12:23 That's cool.

12:23 I mean, I'm a huge fan of the liberal arts education.

12:26 I feel like it's good to be a well-rounded person.

12:28 But I'm not entirely sure how much college should drive career training.

12:34 You know, more like be a good person in society and be well-informed.

12:39 Now go learn the thing, right?

12:41 Yeah.

12:42 And I mean, it's also good for networking.

12:44 It's good for, you know, expanding your interests beyond whatever you learned in high school.

12:48 But, you know, most of the people that we get are people who are changing jobs, not people fresh out of high school.

12:54 I've had a few people who are fresh out of high school, but most folks have gone through, you know, they might have an undergraduate degree.

12:59 I've even had a few people with CS degrees, but they've had a job before.

13:03 They want to do a different job.

13:05 They don't need all the ancillary stuff.

13:07 They just want to know how to do a new job, which is fine.

13:09 And we teach them how to do that.

13:11 Yeah.

13:11 Yeah.

13:11 That's cool.

13:12 That's excellent.

13:12 Yeah.

13:14 So let's talk about your, the four frameworks that you chose and maybe even start with just because with the app, because your idea was, I'm going to build the same app in four different frameworks.

13:25 Right.

13:26 So what's that?

13:27 Yeah.

13:27 So the app itself, I tried to keep it as simple as possible while still displaying, you know, the aspects of what a web.

13:33 A framework should handle.

13:34 And so I chose a to do list, which is, you know, everyone knows a to do list.

13:38 So there's not much that needs to be explained in that way.

13:40 So when I get to talk, it's like, Hey, you know what a to do list is.

13:43 This app does that.

13:44 You know, with this, with this application, you can, you can add new users through registration.

13:48 You can log in, log out.

13:49 You can add new tasks, edit existing ones or complete existing ones.

13:54 You can even delete them if you want to.

13:55 And so that's just kind of the backdrop for investigating how these four frameworks work.

14:02 Yeah.

14:02 That sounds pretty simple, but actually it touches on a lot of stuff.

14:05 You've got a data access layer.

14:07 You've got a database.

14:08 You've got forms because you've got to post back information to register.

14:12 You've got like secure user management.

14:14 There's a lot of stuff actually going on there.

14:17 Oh, absolutely.

14:17 And I didn't, I didn't get to go into all of it in my talk.

14:20 I didn't even get to finish writing all the code just because time got away from me, but

14:23 it's not just, I'm going to send some data somewhere and it gets handled.

14:27 It's okay.

14:28 How exactly is it being handled?

14:29 What exactly am I handling?

14:30 And how is every web framework supposed to be doing it?

14:33 And so when I originally wrote this talk, it was looking at each aspect of a web framework

14:39 across all four.

14:41 And then I revised it to look at each web framework one at a time, doing all the things that's,

14:46 that the app requires.

14:48 So I started with Flask and the setup and installation and then getting things up and running

14:55 configuration and then how to make a view.

14:57 So like a view is just a function that handles a request.

15:01 So an incoming HTTP request and sends back a properly formatted response.

15:05 And the benefit of web frameworks, and this is definitely something that my students learn

15:09 because I have them build a web server from scratch as part of the course, is that you

15:14 don't have to worry about a lot of the stuff that goes into building a response or parsing

15:20 an existing request.

15:21 There's so many different ways that an incoming request can go wrong.

15:24 And you don't have to think through all that logic.

15:27 You want to think more about how your app is supposed to work.

15:29 Right.

15:29 You could open a socket and just go to town on that thing.

15:32 Right.

15:32 But right.

15:33 You know, splitting strings and using regex to find different parts of the request headers

15:37 and all that stuff.

15:39 But who wants, no one wants to do all that.

15:41 No, no, no.

15:41 Something that's already pre-built.

15:43 And you know, people smarter than myself have done it.

15:47 So why should I do it myself?

15:48 Exactly.

15:48 And there's people actively working on it.

15:50 So the four frameworks you chose, you chose Flask.

15:53 And then Tornado, I thought, was an interesting option.

15:56 Yeah.

15:57 I had heard about Tornado.

15:58 And I didn't have any idea what it looked like, what it would do.

16:03 But I heard the word async.

16:05 And I was like, that should be useful.

16:07 That sounds fun.

16:08 Yeah.

16:09 That sounds really fun.

16:09 That's cool.

16:10 So yeah, I'll dig into it.

16:11 Yeah.

16:11 And you've got Pyramid and Django.

16:13 So those are the four.

16:14 And let's, I guess, start with Flask.

16:17 It's on the smallish side, right?

16:21 It doesn't bring a lot to the table.

16:22 It's one of these micro frameworks.

16:23 But for your example, you still use Flask, Flask SQLAlchemy, and Flask HTTP Auth, right?

16:29 Right.

16:30 And I have to have those external packages because Flask really is the barest bones.

16:34 Where a framework, it's just, you know, you can make a function that handles requests

16:39 and returns a response.

16:41 And that's all that Flask does on its own.

16:44 Yeah, pretty much.

16:44 And so if you want to talk to a database, or if you want to do any sort of authentication,

16:49 you've got to use something else or write your own.

16:52 Yeah.

16:52 So like Flask, and there's benefits and drawbacks to each of those.

16:57 So like if you want to use a database like a MongoDB database, you download the package

17:01 that someone has written to use Flask MongoDB.

17:04 Or you can even just write, you know, straight up queries on your own without using a go-between.

17:12 And then that'll work.

17:13 Right.

17:14 Just write a couple lines of code and like sort of piece it together yourself.

17:17 Right.

17:17 And that's something you can do, especially if you only need a very small application.

17:21 Flask is the way to go.

17:22 Once you want to start doing more of the classical CRUD application, CRUD being create, read, update,

17:28 and delete functions, you're going to start wanting to move away from Flask.

17:32 Just because it can still do those things, but it becomes harder.

17:36 Yeah, you do more of the legwork yourself.

17:38 Yeah.

17:38 So maybe let's go through, like, we'll kind of go through the same section for each framework.

17:42 For Flask, let's talk about like, how do you like connect to the database and sort of incorporate that?

17:49 Sure.

17:49 So I'm a fan of the 12-factor application.

17:53 Give us the quick summary on what 12-factor app is, if you can.

17:57 Sure.

17:57 And the way that I'm trying to connect to it here is that one of the parts that's important is having your code not change between development production.

18:05 Instead, be dependent on your environment and the variables that are set in your environment.

18:09 So my application should have the same code running, whether it's on my own machine or on Heroku or on AWS.

18:17 All that I'm changing are some flags, like, you know, am I in debug or not?

18:21 Is my database a local database or is it a remote database?

18:24 And so one of the ways that I do that is I use an environment variable.

18:27 I call it database URL just because I use that everywhere.

18:30 That's used in several places.

18:31 One of the places it's used is Heroku, so it makes it very easy for that.

18:35 So I use an environment variable called database URL to point to my database's URL.

18:40 And then I use an environment variable called Flask Gap to point to the directory of my Flask Gap.

18:45 And then I put all my working code in the location of my Flask Gap, that app.py file.

18:52 Right.

18:52 Yes, you just have the app.py.

18:53 And basically, you could just use Flask.sqlalchemy.

18:57 And what is that like?

18:58 Is that integrated?

18:59 It creates a sort of a base model, right?

19:01 If you do SQLAlchemy on its own, you've got to create the declarative base and do all of that stuff.

19:06 And so the Flask SQLAlchemy kind of does a little bit of that work for you, right?

19:11 Yeah, Flask SQLAlchemy takes care of a lot of that work for you.

19:14 It just gives you this model object that you use.

19:16 That includes the declarative base and all the SQLAlchemy machinery.

19:20 But just lets you focus on building the actual objects that you want to insert into your database.

19:25 And it also does a nice thing for you where it includes a method.

19:29 No, I guess it's not a method.

19:30 It's an attribute on the model object that you create that will talk to the database for you.

19:35 So you can query for one object by just saying, you know, object name.query.all.

19:40 And that gives you all the instances of that object in your database.

19:42 Oh, yeah.

19:43 That's really cool.

19:43 Because otherwise, you have to, like, create a session and then use the session to create the query.

19:47 Right.

19:48 Yeah, so it's kind of like a convenience wrapper around the SQLAlchemy stuff.

19:52 But for the models and everything, you just define them the same, more or less.

19:55 Right.

19:55 You set up columns by declaring columns.

19:58 Yeah, it's really easy.

19:59 You set up columns by declaring columns.

20:00 If you want a primary key field, you say, this column is going to have a primary key.

20:03 And it's going to be true.

20:05 Like, the primary key flag is true.

20:06 If you want to set up an explicit table name, you have a table name attribute that you set in your class.

20:11 Any other behavior you want to have.

20:13 You know, it's still a class in Python.

20:15 So you can still add whatever methods you want to do special things.

20:18 Right, right.

20:18 I find I don't do that often, but a little bit.

20:21 There's sometimes there's just, like, a few things you want to compute in Python related to that entity.

20:28 And you're just like, oh, it just needs, like, a property or something here.

20:30 And it'll be perfect.

20:31 Exactly.

20:32 And one of the things that I use that for was, so in my models, I have two models.

20:36 I have a task model, which is the actual, like, to-do list task.

20:38 And then I have a profile model, which is the user who has the tasks.

20:42 And one of the things I wanted to do was when you register a user, automatically give them, like, they joined.

20:48 And then also automatically give them, like, a secret token that you can use to log in and log out with.

20:53 And that's not handled by SQLAlchemy.

20:56 And so in the init method, I just say, you know, do whatever you were going to do in your init method, but also set these properties on the class.

21:03 Yeah, I really like that.

21:05 This portion of Talk Python to me is brought to you by Linode.

21:09 Are you looking for bulletproof hosting that's fast, simple, and incredibly affordable?

21:13 Look past that bookstore and check out Linode at talkpython.fm/Linode.

21:18 That's L-I-N-O-D-E.

21:20 Plans start at just $5 a month for a dedicated server with a gig of RAM.

21:25 They have 10 data centers across the globe.

21:27 So no matter where you are, there's a data center near you.

21:30 Whether you want to run your Python web app, host a private Git server, or file server, you'll get native SSDs on all the machines,

21:38 a newly upgraded 200 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.

21:45 Do you need a little help with your infrastructure?

21:47 They even offer professional services to help you get started with architecture, migrations, and more.

21:54 Get a dedicated server for free for the next four months.

21:57 Just visit talkpython.fm/Linode.

22:02 So then also the Flask SQLAlchemy comes with sort of a create all function that would be the, you go get the metadata and then do that on the base, right?

22:12 There's like a little bit of a nice utility method there.

22:14 Then when you talk, you talk about views.

22:16 So in Flask, views are basically functions with a decorator.

22:19 And they're super simple, right?

22:21 Yeah, and that decorator, yeah, absolutely.

22:23 That decorator is the app.route.

22:25 So like your Flask app is the app object.

22:27 And everything goes through there, including the routing.

22:31 And you decorate every function that you want to be a view with app.route.

22:35 And you pass as an argument to that decorator the actual route that's going to connect to this view.

22:39 So let's say I want to have a home route.

22:41 I say slash home is that route.

22:43 For my decorator, I say, you know, the app symbol, app.route, and then slash home for my route.

22:50 And then directly underneath that, the function is going to be whatever handles that route.

22:54 So when the home route is accessed, that function will run kind of like a callback in JavaScript.

22:59 Yeah, the other thing that's interesting about Flask, I think, is this global request object that's kind of always there, right?

23:06 That was one of the weirder aspects of Flask.

23:09 I'd never encountered that before using Flask.

23:11 Because typically, like with other web frameworks, the request object is populated.

23:15 It's a parameter.

23:16 Just as a local variable.

23:17 Yeah.

23:17 It's a parameter in a function or a method in a class.

23:20 But it's just populated for that one instance.

23:24 And it's only usable by that one function unless you pass it somewhere else.

23:27 With Flask, the request object is a global variable.

23:30 It is the incoming request.

23:32 And it's usable not just by your view function, but any function or anything that you have in that file, that script file.

23:42 You can use it to do whatever you want to.

23:43 So you can set up, you know, background tasks if you want to use that request object without any actual reference to your view.

23:49 Yeah, and that's kind of funky.

23:51 But it also makes it pretty easy.

23:53 I had the guys that did Quart.

23:55 The guy who did Quart on, and Quart is an asyncified version of Flask.

24:01 And this type of stuff was one of the things that made making it async really challenging.

24:05 Because how do you control when the request thing points at the right one?

24:12 And then you release the thread, another one runs.

24:14 It's like, it gets a little tricky.

24:15 Yeah, I have no idea how that would work, honestly.

24:19 It took some crazy monkey patching, as from what I understand.

24:21 Good God.

24:22 I mean, it's certainly possible, and I'm sure there's use cases for it.

24:26 But I can't imagine the mess that must be under the hood when you're trying to do that.

24:29 Yeah, it gets interesting.

24:30 Yeah.

24:31 All right, speaking of interesting, the one that is the most out there of the four that you chose, I think, is Tornado.

24:38 And I'll just read the quick summary for Tornado that they put on their website, like the paragraph.

24:43 So Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed, which is like some interesting early social media, for a non-blocking network I.O., right?

24:54 So it scales to tens of thousands of open connections and makes it ideal for long polling, WebSockets, and so on.

25:00 So if what you're doing is waiting on stuff, I'm calling web services, I'm calling database things, and I want to not block up my web tier when that happens, like Tornado is pretty cool.

25:10 There's other options that are more modern, but this is like a really popular one.

25:14 Yeah, definitely.

25:15 Yeah, Tornado is useful for if you want to have a long-lived connection or if you want to do anything that requires some long-running input-output.

25:24 This particular use case, this to-do list, is not the best place for Tornado to be used.

25:31 It's still like you don't need to do async stuff with Tornado.

25:34 You can use it just like a Flask or like a Django.

25:37 It'll work the exact same way.

25:39 It just handles requests and sends back responses.

25:41 But if you do have a long-running task like a database query that's going to take a while to aggregate some data or maybe you need to send a request to somewhere else,

25:50 you can set up your views as coroutines that'll run in their own time and still free up the web service to handle other requests or do other operations.

25:59 And it's really cool that way, and it's actually fairly simplified, where all you really need to do is know exactly which part of your code you want to, or which will be long-running.

26:08 You set that up as being what's called a future object, something that's going to be running in the future, and set up the method as being a coroutine.

26:14 Tornado will handle all the rest.

26:16 You don't have to worry about the event loop.

26:17 You don't have to worry about any of, well, most of the other asynchronous issues.

26:22 It's just, it's done for you.

26:23 Yeah.

26:24 And so you're using SQLAlchemy here as well.

26:26 And what gets interesting is SQLAlchemy itself is not async-enabled, coroutine-enabled, or things like that, right?

26:34 So you have tornado-SQLAlchemy, which lets you do that, right?

26:38 Mm-hmm.

26:39 And the way that it does it is by setting up a context object where, so in that context, you have access to this session.

26:47 And then whatever you would do with that session gets handed off as a task to your async event loop.

26:53 And so you hand it off to the event loop.

26:56 Your event loop continues to run.

26:58 And you're not necessarily waiting for that process to finish before you handle your next request.

27:04 It's just that when that process does finish, and the event loop is aware of that, then that response to that specific user is sent back as it needs to be sent back.

27:13 The thing that it's not doing for you is, like, if you have some long-running computation, that's not going to be handled by a tornado.

27:19 It's really just for input-output from some external service or from, like, clients.

27:25 Right, exactly.

27:25 You've got to have one of those things to make a future and wait upon it, right?

27:29 And if that's just compute, it's just going to block up the same thread anyway, so.

27:32 That's an interesting thing.

27:33 Like, I was never actually trained in understanding async.

27:37 And so...

27:38 It's pretty mind-bending the more you dig into it.

27:40 Yeah, it really is.

27:41 It really is.

27:42 It was interesting.

27:42 And this goes back to PyCascades, where, like, I had kind of, like, dipped my toes into it with Tornado, but I was like, oh, I don't really know that much.

27:49 I know I can decorate this method with a coroutine.

27:51 It'll make it a coroutine.

27:53 And then I got the privilege of being able to sit next to Guido during the speaker's dinner after the first night.

27:58 And he talked to me for a while about, like, how async works.

28:03 And I still didn't quite fully grasp it.

28:05 But it was really interesting in how Python is still being a single-threaded process, but it's handing off tasks to be working in the background.

28:14 And then I tweeted about, like, okay, I'm really going to be serious about learning about this async stuff.

28:19 And he tweeted back at me, and he was like, hey, you want to check out this book?

28:22 And it's been great thus far.

28:25 I've been reading.

28:25 I've read through it about this.

28:27 This is one chapter in this book about twice now.

28:28 I'd say my understanding is at about 25% level.

28:31 That's awesome.

28:32 What was the book you recommended?

28:33 It was...

28:34 Let's see if I can put...

28:35 I don't have it on this machine.

28:36 Do I?

28:36 Let's see.

28:37 I'm going to look for it.

28:39 And if I find it, I'll send it to you.

28:41 Yeah, we'll put it in the show notes or something like that.

28:43 Yeah, sure.

28:43 Absolutely.

28:43 But it's an open source book about...

28:47 It's very sharp.

28:48 It's about the architecture of software.

28:50 Oh, is it the one where they build all these different things and 500 lines of code or less?

28:54 Yes, that's what it was.

28:55 Is it the article of Jesse Davis and Guido's article, maybe?

28:59 Yes, that is the exact one.

29:00 Yeah, that's a good one.

29:02 That is a really good one.

29:03 A web crawler with asyncio coroutines.

29:06 And it actually builds up what a coroutine is from ground level.

29:10 It starts with your blocking sockets.

29:12 And then it's still sockets, but non-blocking sockets.

29:15 And then it goes to an actual web crawler using coroutines.

29:19 And it's pretty awesome.

29:20 Yeah, that's a really cool one.

29:21 And I love the 500 lines or less aspect of it.

29:23 That's pretty cool.

29:25 Yeah, and for being 500 lines or less for such a complex topic, they do a really good job of explaining what async is and how it's supposed to work in the context of Python.

29:33 Yeah, yeah, that's really cool.

29:34 All right, so we've got these async coroutine view methods.

29:39 Are they methods or are they classes in Tornado?

29:41 I can't remember.

29:42 So the views themselves are classes.

29:44 And you connect the views to routes in Tornado's central application object.

29:48 You can have multiple applications running at the same time, which goes back to that event loop thing.

29:52 You can have in your one Tornado project four or five applications running at the same time, doing and handling different things if you want to.

30:00 But the actual method that gets run depends on what kind of requests you come in.

30:03 So you know that you have several types of HTTP requests.

30:06 You can get, post, put, delete.

30:08 Those are the main ones.

30:09 There's other like hen, option, whatever, but normally you should use those.

30:12 And then there are corresponding methods for those.

30:14 So when an incoming get request comes in, whatever code that I've written for the get method will get run for that request.

30:22 And the response is built from that request, from that method, and sent back to the client.

30:26 Yeah, that sounds really cool.

30:27 So the sort of fundamental building block in Flask is you have a decorated function.

30:33 The fundamental building block here is I have a class.

30:35 One URL points at it, but it can have different methods for the various HTTP verbs.

30:40 So it's a little restful in that sense.

30:43 It's a little restful in that sense.

30:44 It works really well for a restful API.

30:46 And the benefit of having it be a class is that you can set some instance attributes to only run for that one class, for that one type of request.

30:57 You can think of them as, you know, semi-global things that only apply to that class.

31:01 And you can have other methods in that class that work just for that class and whatever you want to do with those methods for those specific kinds of requests.

31:08 For those methods, in this particular case, the to-do list, I add some methods to some base request handler for constructing responses, for setting default headers, for converting incoming data from post requests into Unicode, because they come in as byte code instead.

31:25 Sorry, byte strains instead.

31:27 That's really simple.

31:28 It's just a method of the class.

31:29 Yeah, that's cool.

31:30 I find that that's a really nice design pattern, because there's probably like five or ten things like every web method wants access to.

31:37 And if you put that in a base class and bundle it up, that's sweet.

31:39 And that was very simple to do.

31:40 Yeah, cool.

31:41 And then for the SQLAlchemy, even though it's the Tornado SQLAlchemy, you still basically define it exactly the same, right?

31:47 The declarative base and all that?

31:48 It is almost the exact same thing as Flask.

31:52 In fact, when I first written this project, I wrote it in Pyramid.

31:56 And then when I was going through Tornado, I was like, oh, I can just copy and paste everything I wrote for Pyramid into Tornado and copy and paste everything I wrote for Pyramid into Flask, because it's all SQLAlchemy under the hood.

32:06 And that's one of the things I like.

32:07 If you have an ORM or like I use Mongo a lot, so an ODM that you really like, they kind of are portable, right?

32:13 You learn the data part.

32:14 It's almost like the 12-factor app idea that you were talking about.

32:17 Like, you understand this part of your architecture independent of the framework, right?

32:23 Like the pieces, you put them together.

32:25 They're not like locked.

32:26 And they're not like the one in the same, unlike, say, Django, which we'll get to in a second, right?

32:31 Right, right.

32:32 Yeah, that's the benefit of using things like Pyramid or Flask or Tornado.

32:36 And they're similar in the way that there is some basic framework, but all the rest is just building.

32:41 It's just Legos.

32:42 Yeah.

32:42 It's all the same stuff.

32:43 Nice.

32:43 So let's move on to Pyramid.

32:46 I think Pyramid lives somewhere in between Flask and Django, maybe a little closer to the Flask world.

32:50 But I really like their philosophy.

32:52 They're the start small, finish big, stay finished framework.

32:55 And they say their philosophy is it should be very quick and easy for you to learn to start with a web framework.

33:02 But the stuff that you need as it grows more complex is just there.

33:06 And so that's kind of a nice philosophy, I think.

33:09 One of the things that was nice about Pyramid is that I use the cookie cutter template for building a Pyramid application where cookie cutter is a separate Python package that you download and then you point out a repository to copy over some files for you to build your application.

33:26 There are cookie cutter templates for Flask, Tornado, and even Django.

33:29 I didn't know how to use those as well as I knew for Pyramid.

33:32 So I just used the one for Pyramid.

33:33 Yeah.

33:33 It's the official way to get started with Pyramid where the others you theoretically could use cookie cutter, but it's like there's some other sort of official starting point.

33:42 Yeah.

33:42 Actually.

33:44 So it's interesting that you say that because when I first started teaching Pyramid almost two years ago, cookie cutter was not the way to do it.

33:51 It was.

33:51 I was using Pyramid 1.8.

33:53 Yeah.

33:53 It was pcreate.

33:53 Like when you install Pyramid, it installs for you a command.

33:56 It's actually still there in the current version of Pyramid.

33:58 Yeah.

33:58 If you still want to use it.

33:59 I think it delegates to cookie.

34:01 It just is a wrapper around the cookie cutter now, I think.

34:03 Oh, is it?

34:03 I haven't actually looked at it.

34:04 I think so.

34:05 I'm not entirely sure either.

34:06 That makes sense.

34:07 Okay, cool.

34:08 But yeah, like the pcreate command would say, okay, you want to create a pyramid application.

34:14 You want to do certain things.

34:15 There are various templates you can use.

34:17 The basic pyramid template says, okay, you have some main function, which is your main configuration.

34:22 Maybe you want to hook up some views.

34:23 Maybe you want to hook up some routes.

34:24 Whatever.

34:25 We got you.

34:26 With the SQLAlchemy cookie cutter template, it says, oh, you want a database?

34:31 Well, instead of having you write your own, because we know you don't know what you're doing,

34:36 we're going to give you a script for initializing your database.

34:40 Here it is.

34:41 It's called initializeDB.

34:43 It does exactly what you think it's supposed to do.

34:45 Without you worrying about the actual implementation details.

34:48 One of the things that I wish they had was an Alembic template.

34:52 Maybe they have one now.

34:53 I haven't checked in a few months.

34:54 But that'd be cool, too, because one of the things that's hard to teach what I'm doing

34:59 pyramid is, you know, you can actually, if you know how to use Alembic, you can set up

35:04 these things called migrations, which are snapshots of your model as you change it over time.

35:08 And that's a lot easier and better for production than just destroying it all and rebuilding it

35:13 from scratch every single time you want to make a change.

35:14 Yeah.

35:15 The migrations are where that get tricky.

35:16 And so the fact that if that were built in, that would be sweet, right?

35:20 Yeah.

35:20 And I'm sure that at this point in time, someone's done it.

35:22 I just haven't looked.

35:24 Maybe.

35:24 I mean, one of the things that you could do for your courses is you could take one of

35:27 these cookie cutter templates and make one that's like a little more focused on what

35:31 you guys are trying to end up with the end goal.

35:34 Like I have my Python for entrepreneurs course, which has just a crazy amount of different

35:39 things brought into it, like bootstrap set up in a certain way and all sorts of templates.

35:43 And so I actually created a cookie cutter template that is the, like, if you wanted to take what

35:48 we built through the 20 hour course and start a new project from it, you would just run that

35:52 new cookie cutter template and like you would start basically the end of the course.

35:56 Yeah.

35:56 That's awesome.

35:57 Yeah.

35:58 It's really fun.

35:58 So that's a great idea.

35:59 Yeah.

35:59 It's really like you teaching the same thing.

36:01 It's similar things you could like, you could help yourself by like, tweaking one of these and forking it.

36:06 Yeah.

36:06 That might be a thing that I'd do in the future.

36:09 I have been trying, like, as I've modified the course.

36:12 So it's worth noting that I didn't, I wasn't the one who created the course.

36:15 The course was created by this awesome guy, Chris Ewing, great developer, great friend,

36:19 extremely smart.

36:20 And he created the course with Pyramid in there.

36:25 He had done Flask before, but he decided to go with Pyramid instead as just kind of a more

36:29 basic framework that could do a lot.

36:32 And his idea was to not have the things that they learned be too heavily tied to just the

36:39 course that we teach.

36:40 Because when they get out in the real world, they need to be able to understand what's happening

36:44 and not just fall back only onto what we taught, but be able to build up from scratch whatever

36:49 they need to build up for whatever job they have.

36:52 The benefit of using someone else's cookie cutter template is that someone else has done

36:57 it.

36:57 It's more likely to be used widely if someone's building a project and they can kind of just

37:03 get direct, they can feed directly into that pipeline.

37:05 But I think now that you mentioned it, I'm going to, I'm going to see if there's an Alumbic

37:09 template out there for Pyramid.

37:11 And if there isn't one, I might actually try to write one.

37:13 Yeah, it'd be really cool.

37:14 It would be useful.

37:15 Yeah.

37:15 I don't mean to derail you, but I do find this, these cookie cutters are really interesting

37:19 to roll with.

37:19 So this is how you get started in Pyramid.

37:21 And let's say the terms of views, the default fundamental building block is very much like

37:27 Flask, right?

37:27 Oh yeah.

37:28 It's just a function with a decorator.

37:30 The difference between Pyramid and Flask is that your decorator, so your routes in Pyramid

37:36 are separate from your views.

37:38 They are just a listing of routes in, you can put them in a separate file, you can put them

37:42 in your main configuration directly, and they have a name.

37:45 So like, again, the home route, it would be called home, and then the actual pattern that's

37:52 supposed to be matched to go to that route.

37:53 And then your view has this view config decorator where you say, okay, here's the name of the

37:58 route that I want you to connect to.

38:00 Here's also the way in which I want you to render the response of this view.

38:04 You can have, there's several options.

38:06 One of those is JSON, so I can take my response, like if I pass a dictionary to my return value,

38:11 then my response will just be a dictionary, and that's JSON serializable.

38:14 Or I can make it, I can use a template like a Jinja template or a Chameleon template or any

38:19 other template system that I want to, and just pass my response to that template, and Pyramid

38:24 will build a response for me and send it back to the client.

38:25 You can also go with the Tornado style and create these like handler classes that get

38:31 one URL.

38:31 You can, or they're called view classes, I think.

38:34 You create handler classes.

38:35 There's like a whole bunch of different ways.

38:36 And I think that's one of the challenges of Pyramid.

38:39 It's the framework I like most.

38:40 My web apps are built in it.

38:42 But I do feel like there's all these different ways to do the same thing.

38:45 So I'm never like, am I doing it the best way?

38:48 Or I'm just doing it the way that I know?

38:50 You know what I mean?

38:51 There's always a better way.

38:52 It's more a matter of, my students often come to me with the question of like, is this best

38:57 practice?

38:58 Is what I'm doing best practice?

39:00 And my response is always, well, best practice is oftentimes just defined by the person who's

39:05 paying you.

39:06 What do they want?

39:07 It's a trade-off too, right?

39:09 If I'm building Google, I'm making different trade-offs than if I'm building a small hotel's

39:15 website.

39:16 A best practice for Google is wasting money for the hotel and vice versa.

39:20 The point there is that it always comes down to your use case, right?

39:23 If your use case would be better served by using class-based views and having the mix-in

39:30 pattern that Django has, then that's your best practice.

39:34 But if your use case is better served by a function, then use the function and be okay

39:39 with it.

39:39 As long as the thing works.

39:41 That's what matters more, is that the thing that you're building works.

39:44 And then you can optimize as you need to for your specific use case.

39:48 Yeah, for sure.

39:49 All right, so you brought up Django.

39:50 Let's move on to Django.

39:52 So the summary there is it's a high-level Python web framework, and it encourages rapid development

39:58 and pragmatic design.

39:59 So it comes with lots of pre-built stuff, and the building blocks are kind of large.

40:06 They're more like Duplo rather than Lego building blocks.

40:09 I like to think of them as, right?

40:11 Exactly.

40:11 I would even say they're more like, if you know Power Rangers, where the robots come together

40:18 to make one larger robot.

40:19 There's still machinery in the individual robots, but their job is not to be inspected individually.

40:26 Their job is to make one larger conglomerate.

40:30 Yeah, yeah.

40:30 One of the things that Django doesn't say in their description is that it is extremely opinionated

40:35 about the way that things should be done.

40:37 And so, yes, there are function-based views in Django.

40:40 There's also class-based views in Django.

40:42 There's the ability to talk to a database in Django, but the database you're talking to should

40:46 probably be a SQL database.

40:47 And the way that you build models in Django, at least through the tutorials and the documentation,

40:52 assumes you want rows and columns.

40:55 There are ways to incorporate a thing like Mongo into a Django application, but that takes a lot

41:00 of extra legwork that you may not want to do.

41:02 You're kind of fighting.

41:03 You're going against the grain a lot of times, even though it's possible, I feel like.

41:07 Django, it encourages rapid development as long as you want to do things the Django way.

41:11 Which is oftentimes a good way to do things, but if you want to go outside that norm,

41:17 you're going to have to pull apart some code to do that.

41:19 I think Django is good.

41:20 A lot of people use it.

41:22 It certainly seems to be super effective for people who want to kind of get started quick

41:28 and stuff.

41:29 I personally lean more towards the micro framework because I want to pick that little data access

41:34 layer and that little bit over here and just put it together, you know, but I think

41:38 that's just my personality.

41:39 Yeah, but if you want to start quick and build big to start, then Django is pretty much the

41:44 way to go.

41:45 Yeah.

41:46 So in here, you design the models differently in a similar but different way because you

41:50 use the Django ORM, not the SQLAlchemy style, right?

41:54 Where the SQLAlchemy style has you inherit from this thing called the base.

41:56 It's actually fairly similar with Django.

41:59 When you're building a model, you inherit from Django's own base model, which handles the

42:04 database interaction layer for you.

42:06 And then instead of having columns or column objects, you have field objects, but it's still

42:10 the same thing underneath.

42:11 There are one of the benefits of using Django's fields is that there are some specific keyword

42:17 arguments you can set for specific fields.

42:19 One of my favorites is the auto now add that comes with the daytime field, which says, you

42:23 know, when you create a new instance of this object, then I'm going to just set the date

42:27 time on like for now.

42:28 Whatever now is, that's the date time on this field.

42:31 Yeah.

42:31 And you could do that with SQLAlchemy, but it's easy to make mistakes on it, right?

42:37 Like you could say, instead of saying the now function, you say now with parentheses and you

42:41 get like every model is marked at the time that when the app started, you know, funky stuff

42:46 like that.

42:47 Exactly.

42:47 One thing that's always kind of put me off on Django is the way you define URLs is like

42:53 regular expressions.

42:54 That's always sort of driven me crazy.

42:57 Yeah.

42:57 I mean, to a degree you do that in pyramid as well.

43:01 If you want to have any variable routes.

43:02 Right.

43:03 If you want to, you say this can only be an integer.

43:05 Right.

43:05 Here.

43:06 Right.

43:06 You say the variable name, but if you want to constrain it, then it's a regular expression.

43:10 Up through Django 111.

43:11 I'm not sure if that's still the case in Django 2, actually, because they have the pattern

43:14 now.

43:14 They changed it.

43:15 They changed the new pattern to make it a lot nicer.

43:17 Up through Django 111, which is what I built the app in, is you have to have a specific

43:22 regular expression to be matched for your pattern.

43:24 And the way that you, like the whole pattern itself is a regular expression, not just the

43:29 variable part.

43:30 Whereas with Django 2 now, it's a little bit more natural, a little less nuanced for just

43:35 regular expressions.

43:36 You can still do the old way if you want to, but they're encouraging you to use the new pattern

43:40 that isn't a regex unless you absolutely need it.

43:43 Yeah.

43:44 So instead of having like a regular expression for the integer, you know, you just say angle

43:50 bracket int colon, you know, oh, so nice.

43:53 Right.

43:54 But if you want an integer that's only, you know, that must be four numbers long, then you

43:59 want to get more and get more into doing regular expressions.

44:01 Yeah, that's cool.

44:02 All right.

44:03 So you went through this whole experience.

44:05 You went through these four frameworks.

44:07 And to be honest, you just scratched the surface.

44:10 There's a bunch more web frameworks like there's, there's bottle and there's webbed pie and there's

44:15 There's cherry pie.

44:16 There's sanding and cherry pie.

44:18 There's hug, which is apparently a web framework.

44:21 There's, yeah.

44:22 Which is based on Falcon, which is another web framework.

44:25 It's like, oh my gosh.

44:26 So just to like, on one hand, this is just a sampling, but it is a sampling of the major

44:34 elements of the Python web framework.

44:36 So what are your takeaways here?

44:37 My takeaways here for these four specifically, because I just didn't have a time to dig into

44:42 any other ones.

44:42 Well, and it's a talk.

44:43 How many could, how many more could you have actually presented in like 35 minutes, right?

44:48 Right.

44:48 I mean, when I gave my talk, it was at 25 minutes, right?

44:51 And even with just these four and with just a little bit of detail that I gave for each

44:55 one, I still ran over time and I had to get cut off toward the end.

44:59 They're shaking that red thing at you like, oh, you're over time.

45:01 Yeah, exactly.

45:04 But my impressions were as follows.

45:06 For Flask, like Flask is good for small tasks or tasks that don't require a database.

45:12 You can still do database stuff with Flask, but it becomes harder.

45:15 So if you're going to start small and stay small and be simple, Flask is the way to go.

45:21 It's really quick to get up and running.

45:23 It's really simple to put together.

45:26 And you can think more about the actual implementation of some of the logic you want to do.

45:30 Pyramid is great if, as the slogan says, if you want to start small, but you anticipate

45:36 getting larger, Pyramid is great for that.

45:38 If you anticipate getting larger and you still want to know what's going on, you want to have

45:43 a hand, you still want to have that do-it-yourself feel, Pyramid will give that to you.

45:48 But it also can hand you some of the pieces to work with so you don't have to do too much

45:52 thinking for yourself.

45:53 Tornado is kind of like an in-between between Flask and Django.

45:58 It can do Flask stuff if you want to do Flask sort of stuff.

46:00 It can do Django sort of stuff if you want to do Django sort of stuff.

46:03 But it's specifically good for any sort of asynchronous work you want to do or if you want to build a

46:08 chat room, that's good for Tornado.

46:09 If you want to have access to more of the bare networking layer of a web framework, Tornado

46:15 is good for that as well.

46:16 Django is if you want to build big and stay big, if you anticipate a lot of complexity

46:21 and you don't want to think too much about the details, you want to think more about how

46:24 it's supposed to all fit together, Django is good for that.

46:27 All right.

46:27 That sounds pretty good.

46:28 What other frameworks were you thinking about or have you thought about that maybe?

46:33 We sort of touched on them a little bit, but what else did you consider for this list?

46:37 I was thinking, so it's interesting.

46:38 One of the things that I only noticed after I started teaching about web dev is that we use

46:43 a Jupyter Notebook, which is a popular data science tool for displaying your analysis,

46:50 displaying your code.

46:51 When you install Jupyter Notebook, let me just check if I could be installing it right

46:54 now.

46:54 When you install Jupyter Notebook, one of the dependencies is a web framework.

46:58 And the web framework is Tornado.

47:00 I think in the past it might have been Twisted, which is another asynchronous web framework.

47:04 I didn't get a chance to look into it.

47:05 From what I understand, it's a little twisted for writing.

47:09 But yeah, that's another web framework that I kind of wanted to get into.

47:12 I had seen Web2Py, but never actually used it.

47:15 My friend Chris Ewing, he's a big proponent of Plone, which is an older web framework where

47:20 Pyramid learned a lot from what Plone used to do.

47:22 It's still around.

47:24 Yeah, it's almost like the next generation of Plone, almost.

47:27 The same people seem to work on it and stuff.

47:29 Yeah.

47:29 It's got some same idioms.

47:32 When I started doing web dev, I started with WordPress.

47:34 And this is a long way from WordPress.

47:36 And I'm glad I didn't have to go through WordPress again.

47:40 Yeah, that's cool.

47:41 Those are all interesting ideas.

47:43 I guess the other ones that kind of capture my imagination now are the async await enabled

47:48 Python 3 ones, like API star, Sanic, Jepronto, Cort.

47:54 They're sort of the Python 3 only ones that are pretty interesting.

47:58 I think I might look into those then because I've kind of really had the fire lit under me

48:02 for async.

48:03 I feel like it doesn't need to be this esoteric thing.

48:06 You know, it's a pattern in Python.

48:08 It should be learnable.

48:10 Yeah, it definitely should be learnable.

48:11 I think, well, you know, you and I are teachers on one aspect of what we do.

48:16 So we can work on that stuff, right?

48:18 We can build it out for people.

48:19 Yeah.

48:20 Awesome.

48:21 So I want to throw an idea out there that I just had while you're doing this that would

48:24 be amazing that you could build for the community.

48:26 You may be busy and not interested, but it would be amazing if there was like a website

48:31 whose job was to have these comparisons.

48:35 And somehow if it was like open to PRs, like somebody's like, oh, I want to submit an API

48:40 star version of the same app to you.

48:43 And that would be a killer community resource.

48:45 If it like it was available for the community to write this app and sort of write an article

48:49 for every framework that existed.

48:51 The GitHub organization that holds all four of the web frameworks is there.

48:55 You know, I'm perfectly happy to have PRs for that.

48:59 Yeah, that's actually a pretty good starting point, isn't it?

49:01 So we'll be sure to link to your repo for this in the show notes.

49:04 Are you open for people to do PRs for you?

49:07 To do another one?

49:07 Sure.

49:08 Oh, yeah.

49:09 All right.

49:11 So we talked about the web frameworks.

49:12 We talked about your boot camp.

49:14 What else have you got going on that you want to chat about that you'd like to let people

49:19 know about?

49:19 Yeah, absolutely.

49:20 If you're in the Seattle area, the meetup group Puppy, Puget Sound Programming Python

49:23 is really awesome.

49:24 I've been lucky enough to be involved with them for the last year and a half or so.

49:28 And they're really open to new people, to new developers.

49:32 In the last year or so, we have a Slack channel.

49:35 We've started the Q&A channel in the Slack team for people to just ask questions.

49:40 We kind of have our own little Stack Overflow going in there.

49:42 You know, and also just random stuff.

49:44 If you have a pretty much like whatever interest you have, the organizers, Don and Alan, two of

49:49 the people who helped put together PyCascades, they are always open to new ideas, to fresh

49:54 ideas, to people who want to get more involved.

49:55 So that's been cool to be a part of that.

49:58 I've been really lucky there.

49:59 Yeah, that's really great.

50:00 And Puppy seems like a good organization.

50:02 And what was surprising to me is how many people from Seattle and Portland we met in

50:06 Vancouver.

50:07 Yeah.

50:07 Right?

50:08 We left the country to meet people just down the street.

50:10 It's time and opportunity, right?

50:11 Like the conferences bring people together.

50:13 But, you know, when you're at home, you have your work schedule, you have your home schedule.

50:16 Like I have a kid.

50:17 I can't even go out that much anymore.

50:18 I know.

50:19 I have three kids.

50:20 It's like, go out at night?

50:21 What are you talking about?

50:21 Like it's super rare that I can go just hang out at like some tech evening event, right?

50:25 Exactly.

50:26 My wife's teaching or something.

50:27 I got to be home.

50:27 Right.

50:28 Like if I'm going to go to Puppy, I need to know like two months in advance.

50:31 You know, so I can, I can, I can warn my, my, my, my fiance.

50:35 I can warn her again, two weeks later and warn her again, two weeks later after that.

50:38 That, you know, I'm going to be going to this thing.

50:40 We have to get a sitter or like you have to stay home.

50:42 You know what?

50:43 Something's got to happen.

50:43 So we can, there's a lot of, there's a lot of logistical stuff going on in there.

50:47 Right.

50:47 But you go to a conference, you kind of, you've already stepped away from that.

50:50 You've created that space.

50:52 And so it's, it's easy to meet people, right?

50:54 I'm here for this one specific reason.

50:55 Just learn about Python and meet people.

50:57 So that's, that was cool.

50:59 And actually through Puppy, one of the things that I'm trying to do in the, in the coming

51:02 year is to be more of a mentor.

51:03 I've been, I've been the beneficiary of some really awesome people who have been mentors

51:07 in the short term or the long term to give me advice every once in a while, give me some

51:11 advice or, or help me deliver you through a process.

51:13 And I kind of want to give that back to the community.

51:15 And so as a teacher for the last two years, I've been able to graduate about a hundred or

51:20 more people from the Python program.

51:21 And I kind of want to get back in touch with those people and kind of figure out like what they're

51:24 doing, what they're working on, where they're headed, where they're heading in their

51:27 careers.

51:27 Maybe if I can, if I can, even if it's not a mentorship position, more, more like a

51:31 accountability partner, you know, help them move forward through their careers.

51:34 I like being able to have a hand in developing talent in the same way that people help me

51:39 develop my talent.

51:40 It doesn't take a lot of effort on somebody who's experienced on their part to just give

51:44 a little bit of guidance.

51:45 Yeah.

51:45 Because when you're new, you just look around and it's even like, it gets worse every day.

51:49 There are more frameworks.

51:50 There are more languages.

51:51 There are more libraries.

51:52 You're like, I have no idea what to do.

51:53 I know I want to learn this stuff and I want to accomplish this, but where do I start?

51:57 Right?

51:58 Like, how do I go about this?

51:59 And so you can give them some guidance.

52:00 It goes beyond that too.

52:01 It's like, you know, well, you know, I never thought about giving a talk at a conference.

52:05 I never thought about giving a talk at a meetup.

52:07 I hadn't thought about giving a talk at a meetup until my friend Chris said, Hey, you should

52:12 give talks at meetups.

52:12 And I was like, Oh, I can, I can do that.

52:14 That's a thing that I can do.

52:15 Yeah.

52:15 There's no gatekeepers.

52:16 You just have to decide that you can do it.

52:18 Then you can do it.

52:18 Exactly.

52:19 Exactly.

52:19 There are going to be some things that I'm aware of that people who are my former students

52:23 are not aware of.

52:23 Like if there's a panel going on, like, Hey, you should be on this panel.

52:26 We should attend this panel.

52:27 We should meet this person.

52:27 You should go to this coffee meeting and see these people and be aware of these, of these

52:32 concepts of these environments.

52:33 Because, you know, have I found I've been in a lot of different spaces in the last, let's

52:39 say like 10 years or so.

52:41 And what I've noticed in each of those roles has been that most of the work isn't just

52:46 being in the right place at the right time or meeting the right person at the right time.

52:50 And if you never meet that person or if you're never in that place, you don't even know that

52:57 those opportunities are there to be taken advantage of.

52:59 Like I've been able to make some great contacts at Facebook just by going to a hackathon once and

53:05 chatting up one of the organizers of the hackathon.

53:08 Or Twitter has been an amazing resource to meet people, see what they're into, learning

53:14 about other things going on in the field of Python development, just being aware of being

53:18 around and being able to help new people get into that community.

53:22 Yeah.

53:22 I find that a lot of these little hands that you offer to people to help them actually

53:27 come back in unexpected ways.

53:29 And, you know, there's a lot of karma in the world in that sense.

53:32 Oh, absolutely.

53:33 Absolutely.

53:34 I never would have gone to my first conference as an astronomer if my advisor never told

53:38 me about that it existed.

53:39 Yeah.

53:40 And then I wouldn't have met the person who introduced me to Marcel Agueros, who runs the

53:44 Bridge of the PhD program at Columbia.

53:45 If I'd never gone to that, I would probably never be here in Seattle doing Python instruction

53:50 at Code Fellows because I never would have gone for a PhD at UDEL.

53:54 There's so many things in the chain of events that could have gone a different way if I had

53:58 just been in the right place at the right time or talked to the right people.

54:00 I think the big takeaway here is you can't too deeply overthink these little variations

54:06 because your life could be so different.

54:08 Just, you know, sort of chaos theory, right?

54:10 Butterfly wings type of thing.

54:11 Absolutely.

54:12 Yeah.

54:12 Cool.

54:13 All right.

54:13 Well, I think we're getting close to the end of our time together.

54:16 Let me hit you with the two questions that I always put at the end.

54:19 If you're going to write some Python code, what editor do you open up?

54:23 My first instinct is Sublime Text, but I've been going more toward Visual Studio Code

54:27 in the last week.

54:28 Okay.

54:28 Yeah, nice.

54:29 Visual Studio Code with a Python plugin is quite nice.

54:31 Oh, yeah.

54:32 I use Visual Studio Code for like if I just want to open up one file and stuff.

54:35 I'm doing a big project.

54:36 I usually use PyCharm, but I definitely like Visual Studio Code as well.

54:41 All right.

54:41 And then notable PyPI package.

54:43 I love the requests library.

54:44 I also love beautiful soup.

54:46 And then pandas, when I was a researcher, pandas changed my life.

54:50 Like how I did research, how I did analysis.

54:52 I was using NumPy and NumPy arrays.

54:53 Pandas all the way.

54:55 Oh, that's awesome.

54:56 Yeah.

54:56 Pandas is really, really cool and important.

54:58 And to me, requests and beautiful soup literally feels like magic.

55:02 Like there's this web page with stuff.

55:05 And then I write like five lines of code.

55:07 And then I have it like in structured data on my machine.

55:10 I'm like, that just blew my mind that that just happened.

55:13 Right?

55:13 It is really cool.

55:14 Oh, yeah.

55:15 All right.

55:15 So final call to action.

55:17 People are excited.

55:18 Maybe they're about checking out these web frameworks, your project, or maybe even your bootcamp.

55:22 What do you say?

55:23 If you want to talk to me, the easiest way to reach me is on Twitter.

55:26 It's just at Enhan Walker.

55:27 I'm on there literally all the time.

55:29 Probably more than I should be.

55:30 If you're interested in learning how to code, Code Fellows is a dope place.

55:34 If you're in Seattle or in Portland, Code Fellows, great place to learn JavaScript, Java, C Sharp, or Python.

55:40 We have some really dedicated instructors who are really focused on getting people into careers as best as they can.

55:47 All right.

55:47 Awesome.

55:48 Well, Nick, it's really been great to share the four framework comparison with you and the stories.

55:53 Thank you so much for being on the show.

55:54 Thanks for having me.

55:55 I hope this was helpful to somebody.

55:56 Yeah, I'm sure it will be.

55:57 All right.

55:58 Bye.

55:58 Bye.

55:58 This has been another episode of Talk Python to Me.

56:03 Today's guest was Nicholas Hunt Walker, and this episode has been brought to you by Linode.

56:07 Linode is bulletproof hosting for whatever you're building with Python.

56:11 Get four months free at talkpython.fm/linode.

56:15 That's L-I-N-O-D-E.

56:17 Are you or a colleague trying to learn Python?

56:20 Have you tried books and videos that just left you bored by covering topics point by point?

56:25 Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course

56:31 to experience a more engaging way to learn Python.

56:33 And if you're looking for something a little more advanced, try my Write Pythonic code course

56:38 at talkpython.fm/pythonic.

56:41 Be sure to subscribe to the show.

56:43 Open your favorite podcatcher and search for Python.

56:46 We should be right at the top.

56:47 You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct

56:53 RSS feed at /rss on talkpython.fm.

56:56 This is your host, Michael Kennedy.

56:58 Thanks so much for listening.

56:59 I really appreciate it.

57:00 Now get out there and write some Python code.

57:02 I'll see you next time.

57:03 Bye.

57:03 Bye.

57:03 Bye.

57:03 Bye.

57:03 Bye.

57:04 Bye.

57:04 Bye.

57:04 Bye.

57:04 Bye.

57:05 Bye.

57:05 Bye.

57:05 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:06 Bye.

57:07 Bye.

57:07 Bye.

57:07 Bye.

57:07 Bye.

57:08 Bye.

57:08 Bye.

57:08 Bye.

57:09 Bye.

57:09 Bye.

57:09 Bye.

57:10 Bye.

57:10 Bye.

57:10 Bye.

57:10 Bye.

57:10 Bye.

57:10 Bye.

57:11 Bye.

57:12 Bye.

57:13 Bye.

57:14 Bye.

57:14 Bye.

57:15 Bye.

57:16 Bye.

57:17 Bye.

57:18 Bye.

57:18 Bye.

57:19 Bye.

57:20 you Thank you.

57:21 Thank you.

57:23 Thank you.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon