Latest / Talk Python To Me / #161: Django 2.0
Transcript
- 0:00Django has reached a major milestone with its 2.0 release.
- 0:03This puts legacy Python, that is Python 2, fully in the rearview mirror
- 0:07and brings some nice new features to the framework.
- 0:09Join me, along with Daniel Roy-Greenfield,
- 0:13to discuss what best practices we should adopt
- 0:15and which ones are still entirely relevant.
- 0:18This is Talk Python To Me, episode 161, recorded April 23, 2018.
- 0:24Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:42the language, the libraries, the ecosystem, and the personalities.
- 0:45This is your host, Michael Kennedy.
- 0:47Follow me on Twitter, where I'm @mkennedy.
- 0:49Keep up with the show and listen to past episodes at talkpython.fm
- 0:53and follow the show on Twitter via at Talk Python.
- 0:55This episode is brought to you by MangaDB and ActiveState.
- 1:00Please check out what they're offering during their segments.
- 1:02It really helps support the show.
- 1:04Danny, welcome to Talk Python.
- 1:06Thanks for having me, Mike.
- 1:07Yeah, it's great to have you here.
- 1:08I've been looking forward to having you on the show for quite some time.
- 1:11So we were finally able to put it together, weren't we?
- 1:13Yeah, it's been a few years since we first started talking.
- 1:18Yes, it's one of the more drawn-out guest appearances,
- 1:21but you're finally here.
- 1:22And I think the timing is really good because we now have a super major change in the Django world
- 1:29in that we have Django 2.
- 1:30Maybe not major in terms of features,
- 1:33but that's a pretty big step to have, you know, go from 1.something to 2.0.
- 1:38Absolutely.
- 1:38Especially considering that the big change is really under the hood.
- 1:44It's basically the move from Django 1.11 to 2.0 was dropping support for Python 2.7.
- 1:53So from going forward, Django is 3 and higher.
- 1:57There's no other way to do it.
- 1:58Should they just make it super explosive and call it Django 3?
- 2:01I actually have some minor issues with the Django naming structure.
- 2:06And I actually think that maybe you're right.
- 2:08Going to Django 3 might have been better.
- 2:10But the beauty of it, though, is that now the source code is going to be simpler,
- 2:15which means, you know, it'll be more stable.
- 2:17It'll be easier for them to implement more features or for the community to implement more features.
- 2:23Yeah, anything that attracts more contributors and doesn't chase them away with complexity.
- 2:27It's good stuff.
- 2:28Yeah, absolutely.
- 2:29I definitely want to focus some more on this Django 2 only being Python 3 only.
- 2:34But before we do, let's make sure we get to hear your story.
- 2:37How did you get into programming in Python?
- 2:38Originally, I got into programming because it was fun as a student.
- 2:43And as an adult, it was a much better way of making a living than working in restaurants or doing manual labor.
- 2:51And since I started coding, I explored a lot of different languages before settling on Python.
- 2:58I've done FoxPro, Perl, ColdFusion, Java.
- 3:02The list goes on and on.
- 3:04But with Python, I was lucky enough to get employed at NASA.
- 3:10And there, a co-worker named Chris Shenton introduced me to it in the summer of 2005.
- 3:17And at that point, I was so tired of Django's, not Django's, Java's static typing in rigidity that I had delved into ColdFusion of all things.
- 3:30And because I liked the less static typing.
- 3:34And I know static typing is very popular in certain circles, but it's just not what I enjoy.
- 3:40And when I discovered Python and its expressive syntax combined with its dynamic typing system of, you know, where you can, you know, it's strong typing, but not.
- 3:53And I've really enjoyed that.
- 3:54And so I've been hooked ever since.
- 3:56Hence the name PyDanny.
- 3:58Yeah, of course.
- 3:59That's awesome.
- 3:59First of all, what were you doing at NASA?
- 4:02Like what projects were you working on?
- 4:03That sounds really interesting.
- 4:04When I originally got hired there, it was for infrastructure support at NASA headquarters.
- 4:10Is that Cape Canaveral?
- 4:11No, that's actually in Washington, D.C.
- 4:14And there's satellite offices, depending on the contract, in usually in Northern Virginia, but it can change to Maryland, I guess.
- 4:22I'm not sure what the contract state is right now.
- 4:25Those companies can just kind of like spread in a ring around D.C. and like cross borders.
- 4:30It's kind of crazy around there.
- 4:31Yeah.
- 4:32And so what I was doing was a lot of infrastructure support.
- 4:36And one of those things was tying a number of in-house projects to a X500 directory system.
- 4:46That's like LDAP.
- 4:47And what happened was, is that at some point, someone at NASA decided that they were going to switch to an active directory server, which is fine.
- 4:57But they implemented a self-signed security certificate.
- 5:01And the Java version that we were allowed to use in the day, which I think was 1.6, its implementation of Jindy couldn't interact with that.
- 5:11And so Chris Shenton got it to work with TCL.
- 5:16And then we figured out, him and I figured out how to do it with Python.
- 5:20And so that gave us the business reason to bring Python into more of NASA headquarters.
- 5:26That's nice.
- 5:27I'm sure it's playing a pretty important role there now.
- 5:29I believe so.
- 5:30In fact, Chris Shenton has done a number of talks on using Python with AWS Lambda at NASA headquarters.
- 5:38It's really fascinating stuff.
- 5:40And I guess I can probably link to some of his talks at the end of this.
- 5:44Yeah.
- 5:44Yeah.
- 5:45Throw them in the show notes.
- 5:45That'd be great.
- 5:46That'd be really cool.
- 5:47So what was the coolest thing that happened while you were at NASA?
- 5:50I got to start with Python.
- 5:52Yeah, that is pretty cool, right?
- 5:54Very, very cool.
- 5:55Shaking hands with astronauts is a close second to that.
- 5:58So yeah, pretty awesome.
- 6:00It's definitely one of those places that it at least has this really big, noble goal.
- 6:04Like you could go write amazing technology at like a hedge fund, but it's not the same as like, yeah, we're helping launch satellites or do whatever, right?
- 6:11Absolutely.
- 6:12If you ever get the chance to do something like that, by all means, do it.
- 6:16Yeah, cool.
- 6:17And then how do you get into open source?
- 6:19Well, I got into open source because Python is all about open source.
- 6:23And while Java technically is open source, when I was still doing Java, it wasn't.
- 6:30It was a Sun project and then I guess an Oracle project, or it's an Oracle project now.
- 6:36But it didn't have the same ethos and environment and community.
- 6:40Yeah, Oracle doesn't scream like open source to me in terms of just the company culture.
- 6:47I feel it's more likely somebody will show up in like a full on suit than like talk about their open source project coming from there.
- 6:53But I guess there is definitely some stuff happening at Oracle.
- 6:56They just released some pretty interesting new runtime.
- 6:59I can't remember exactly what it's called.
- 7:02Have you heard of this?
- 7:02It's something with a G.
- 7:04I don't pay attention to Java news.
- 7:06It's GraalVM, G-R-A-A-L-V-M.
- 7:11And apparently it's like a new virtual machine for Python and some other stuff as well, like JavaScript and Rust.
- 7:18And I don't know, maybe it's going to be something amazing, but I haven't been paying attention enough.
- 7:22So I guess give them some credit for open source.
- 7:25They are doing some things these days, right?
- 7:26Yes, absolutely.
- 7:28So I got into open source because it was fun and it was exciting.
- 7:34It was great to see people give me a pat on the back as a beginner in a new language and a new tool set that who I respected.
- 7:44And those pats on the back were actually a form of credibility.
- 7:50So I've been, you know, after a few years of doing that, I guess I released my first open source package in 2009.
- 7:56Do you remember what it was?
- 7:57Yes.
- 7:58There are several that I released at that time.
- 8:02The most notable one or the one with the most GitHub stars and downloads is a package called Django Crispy Forms.
- 8:09And it's one of the predominant form libraries for Django.
- 8:13But and at that time I called it Django Uniform.
- 8:16But I had also done some clone packages.
- 8:20And I think there I attempted to write a new logging library because I didn't like Python's logging system.
- 8:27I think everybody goes through that stage as a Python developer, like, oh, I want to write my own logging.
- 8:33The five stages of logging.
- 8:35Yes.
- 8:35So, yeah, I've been doing that since 2009.
- 8:40And since 2013, I've been helping other people build their packages, which has been pretty awesome.
- 8:46It's kind of like paying it forward.
- 8:48That's really cool.
- 8:49How did you get involved with Django?
- 8:50At NASA headquarters, we were doing a lot of clone work.
- 8:54Actually, originally, we weren't doing any web work for my first few years of doing Python.
- 8:59There was essentially no web.
- 9:01And then we got a project where we could use clone.
- 9:04So we use clone and then nothing against clone, but it's a big, complex animal.
- 9:11And so when we had a new project, which was to build a Facebook clone for internal use at NASA, we decide to use Django.
- 9:20And that was at the end of 2008.
- 9:23And so that's when I started with Django, was really the end of 2008, the start of 2009.
- 9:31And it was a bit woolier back then.
- 9:35And it's really come a long way since.
- 9:38Of course, it's definitely come a long, long way.
- 9:40That's awesome.
- 9:42So that's about 10 years ago.
- 9:44What are you up to now?
- 9:44Now I do mix.
- 9:47Well, I still do quite a lot of Python and Django as well, mostly with REST APIs.
- 9:53My not so dark or not so hidden secret is that I actually do a lot of Flask because we use AWS Lambda a lot on our projects.
- 10:05And our rule is if we don't have a SQL persistence store in the back end, then we use Flask that we don't want to staple anything in.
- 10:14Or better yet, if we don't need a persistence store, we use Flask.
- 10:18So that's our go-to tool.
- 10:21And recently we've delved into Vue.js, some modern JavaScript, which has been kind of interesting.
- 10:28I'm a big fan of Vue.js as well over things like Angular and whatnot.
- 10:33What drew you to it?
- 10:35Maybe tell people real quickly just like kind of generally what Vue.js is and then answer my question.
- 10:40Vue.js is roughly analogous to React or Angular.
- 10:46It is an open source front-end JavaScript framework for building responsive, progressive web applications.
- 10:54And it can be used, you can call it by just sticking in a script line in your application.
- 11:01So it's great for bringing over projects that already exist, you know, legacy projects.
- 11:06But also it can be used for new projects.
- 11:09And the virtue that I feel it has over its competitors is it's not as enterprise-y.
- 11:17And I know the word enterprise is a word that there's multiple definitions, but I like the relative simplicity of it and its directness.
- 11:28I don't have to learn a new DSL to work.
- 11:31Well, I guess you do kind of have to learn a DSL to use it.
- 11:35There's the template directives, but it's nothing like having to learn JSX.
- 11:39Yeah, for sure.
- 11:40And yeah, so I think with these frameworks, it's really a matter of taste.
- 11:46But the one thing I do have to say that I like about Vue.js is it's not dependent on Facebook or Google.
- 11:52Vue.js is an independently funded project.
- 11:57So if Google or Facebook decides to drop their projects, there's nothing like that will happen with Vue.js.
- 12:06So there's nothing like the Angular 1 to more modern versions of the Angular transition that you'll have to deal with.
- 12:13That it doesn't require like CLIs and sort of compilation, transpilation steps and all that.
- 12:18It's just like, like you said, drop a script file in, maybe write a little JavaScript and off you go.
- 12:22Yeah, I don't use it much, but when I need that kind of stuff, that's the one I turn to.
- 12:26So, and you also just released a packaging course, right?
- 12:29Tell us about that.
- 12:30So what happened was, is we were invited to PyCon Colombia, my wife and I, Audrey Roy Greenfeld.
- 12:37We were invited to PyCon Colombia to give the closing keynote.
- 12:41And we gave a talk on packaging.
- 12:44And, you know, people seemed to like it.
- 12:47And they said, wow, it'd be great if we could actually learn this in more detail.
- 12:52So we ran a test workshop in Medellin, Colombia, where we, you know, gave out the course material free for a few days.
- 13:01And the response, and we also allowed people to join in from around the world.
- 13:06And the response was really stunning.
- 13:10So we decided, hey, let's make this an ongoing thing.
- 13:14And we decided to charge for it.
- 13:16So that way, that means that we can really work on it.
- 13:19Open source is great.
- 13:21But without funding, you just, everything else is the priority when you're doing volunteer open source work.
- 13:26So that's why we're charging for it.
- 13:29And it's entirely Python neutral.
- 13:31I know we're talking a lot about Django, but this is pure Python.
- 13:36And it is built on proven and awesome tools like Cookie Cutter, pytest, and Tox.
- 13:43It also uses proven software solutions like Read the Docs, PyUp.io, which is the security backend for Pipenv, as well as Travis.
- 13:54And, you know, it's kind of with Cookie Cutter, it's kind of our mission to make packaging easier and better for everyone.
- 14:02Yeah, it sounds like a really cool project.
- 14:03And I love a lot of the tools you mentioned.
- 14:05Cookie Cutter is great.
- 14:06Like you guys, you and Audrey are behind that.
- 14:09That was more Audrey's thing she was leading.
- 14:11But it's still, that's going strong.
- 14:13We could spend a lot of time on that, but maybe save that for another episode.
- 14:17But I think things like PyUp, I use PyUp for all of my web apps to basically tell me if there's any dependency updates, and especially if there's security updates.
- 14:26I think that's great stuff.
- 14:27So, yeah, it's really cool.
- 14:29I do wish packaging in Python was a little simpler, especially for distribution to other people, not to servers.
- 14:37But, yeah.
- 14:38I think...
- 14:39Absolutely.
- 14:40I think the next major thing, well, a thing that could be the next major thing that really ramps up the popularity and usage of Python would be making it simpler to hand out running Python applications.
- 14:51That would be wonderful if it happens, especially because, you know, packaging is so important for, you know, not just open source work or running on servers, but, you know, any kind of architecture, be it monoliths or microservices, you always have repeated patterns that can be captured by installable packages.
- 15:10The problem, though, is we have this, I guess, break between the pip world and the condo world.
- 15:17Bridging that is pretty challenging.
- 15:20And I know the condo team is trying to figure out a way to bridge that.
- 15:25And I'm not an expert on it by any stretch of the imagination.
- 15:29But I know when you're trying to build out projects that'll work in every environment on all the supported Python versions, I know from a lot of personal experience, that's hard to do.
- 15:40And then to get it to work with pip and condo, that's even harder.
- 15:44And even though there's solutions to do it, implementing them, getting them to work is not trivial.
- 15:50Yeah.
- 15:51And we have packaging stuff like CX Freeze, Py2App, Py2Exe, all these things.
- 15:55But it seems to me like they all 95% work until they don't.
- 16:01And so I dream of a day where I can just type Python dash M build or something like that, you know, and just have it like some sort of thing that is part of Python itself that truly perfectly can like replicate itself in a reproducible way.
- 16:17I don't know if that's going to happen in our lifetime.
- 16:19I'm telling you, I told you it was a dream.
- 16:21It was a dream.
- 16:22All right.
- 16:22But stuff that will happen in our lifetime, I'm sure, is Django is going to continue to be going on strong.
- 16:29So let's talk about Django, which is what we're actually here for, even though you've got to package those things up and put them on servers as well.
- 16:35So maybe I know many people know about Django, but there's a lot of listeners, scientists, data scientists, students, and so on who maybe are not super familiar.
- 16:44They probably heard the word, but give us just a quick overview of like what's the elevator pitch for Django?
- 16:48Okay.
- 16:49Django is a high level Python web framework designed to work with relational databases.
- 16:55If you really want to, you can staple in MongoDB or another non-relational data store, but then you'd lose a lot of the virtues of Django.
- 17:05And those virtues specifically are, or the primary virtues, Django makes a lot of the decisions as to which software components you use and the architecture you follow.
- 17:18So that way you can focus on business logic instead of all the other pieces.
- 17:23Because the truth of it is, is that your business logic is never simple.
- 17:28It always gets complex, even for what seems like a simple project.
- 17:32So why not let Django handle that kind of stuff?
- 17:37Right.
- 17:37You know, every single app that I've had that ever has interacted with customers that maybe have some kind of thing they own or they interact with or history or anything has accounts.
- 17:49As soon as you have user accounts, then you have to have the ability to register, the ability to log in.
- 17:55And as soon as that happens, like the very first day, someone's going to say, I forgot my password.
- 18:00So you got to have email so that they can reset their password, right?
- 18:02Like this, all of a sudden you're like, I just wanted to have accounts.
- 18:05And now this is like a week long project, right?
- 18:08This is a significant challenge.
- 18:10I mean, there are companies, Okta and others that make a lot of money solving this problem for you.
- 18:17And Django combined with one or two other packages just does this for you free.
- 18:23Or I guess it's open source, so it's not free.
- 18:25But you get the point.
- 18:26It does it for you.
- 18:27So that's the power of Django is that it gives that to you.
- 18:31And yes, you can customize it.
- 18:34If you want to use SQLAlchemy with Django, you can.
- 18:37All you have to do is import SQLAlchemy.
- 18:40It's not hard.
- 18:42So you can make changes to it.
- 18:44Sorry, I forget the name of the guest, but like a year and a half ago, you probably know better than I do.
- 18:49I had the folks that wrote the book Lightweight Django, which is an interesting.
- 18:53Do you remember who that is?
- 18:55Yes.
- 18:56I can't remember the names.
- 18:57I'm so embarrassed.
- 18:58But I know the book.
- 18:59I know the authors.
- 19:00I'm sorry.
- 19:01I'll try to link to it.
- 19:03Yeah, it was a great book.
- 19:04And they're both really smart.
- 19:05And so that was an interesting look, I thought, inside Django, where it was like, yes, you can have these big projects.
- 19:12But actually, that's just how the start, the sort of create app stuff works.
- 19:16It doesn't have to work that way.
- 19:18We can break it down into these smaller pieces if you want.
- 19:20Yeah.
- 19:20And it's kind of touching on with your SQLAlchemy thing there.
- 19:26Hey, everyone.
- 19:27Michael here.
- 19:27Did you know I'll be doing a three-part webcast series about MongoDB and Python from May to June?
- 19:33We'll see why MongoDB is a great choice for Python web apps.
- 19:36In this series, we'll go through the entire process of building a clone of PyPI, Python's packaging website, over at pypi.org.
- 19:44Everything from building the front end to deploying the web app and MongoDB to the cloud.
- 19:48You'll learn everything from document modeling basics to special considerations for running MongoDB in production.
- 19:54The webinar is free.
- 19:56So just click on the link in the show notes or go to mongadb.com slash webinar slash Python and sign up.
- 20:02See you in May.
- 20:04So some of those ideas or concepts you just talked about are definitely part of what makes Django popular.
- 20:10But, you know, it came on the scene roughly around the same time.
- 20:15There was like kind of a flourishing of web frameworks 10 years ago or something.
- 20:18It seems like looking back, why is it so popular amongst those?
- 20:22Of the other Python frameworks of the time, most of them have, actually, I think all of them have kind of faded away into very much a tertiary position.
- 20:33But when it came on, there was a Python framework called Zope with a CMS that it powered called Plone that was very popular at the time.
- 20:40And that framework grew out of the Java 2 Enterprise Edition version of building stuff, which was very enterprise-y.
- 20:50And the more components you had, the better, to the point that to implement anything trivial like a form just took a lot of work.
- 20:58Django made that, compared to projects of the time, very trivial to do.
- 21:05And since then, it's maintained its popularity, even against libraries like Flask, which, you know, like I said before, I use.
- 21:13And it's many clones, some of them who are asynchronous.
- 21:16It does this because it, one, it has market presence.
- 21:21And it makes a lot of these decisions for you.
- 21:24Instead of, you know, as I mentioned before, instead of figuring out which package or component to use out of the box, Django does that for you.
- 21:32So that way you can implement your project and then not have to, you know, if you want to replace it later as business needs dictate, you can.
- 21:41But out of the box, it just gives you a ton of stuff.
- 21:44It has the same batteries-included approach that Python does.
- 21:47Yeah, that's cool.
- 21:48I feel like it's easy to get kind of a hindsight bias or a curse of knowledge or whatever you want to call it, where you, as an experienced developer that's been working in Python for a long time, you're like, oh, yeah, I'm going to use this package for this.
- 22:01And that package for logging, and that package for mail, and that package for data access.
- 22:05And it's easy to think, well, I just want to grab my little favorite pieces and put them together and create, like, this little super web project that I'm working on, which is actually how I work a lot of the time myself.
- 22:17But it's when you're new, those are not necessarily joyful things, right?
- 22:23It's, like, super overwhelming.
- 22:25Like, there's all these different databases.
- 22:27Each of them have many ways to talk to them, either directly or through a variety of ORMs or ODMs.
- 22:33And it's just, it's a lot, right?
- 22:36And so I feel like Django does bring quite a bit for, you know, a significant number of people to say, here's what we prescribe.
- 22:44Put in the pieces that you want of logic.
- 22:47Absolutely.
- 22:47And because it's Python, the other thing that's nice, and this is just Django or any Python web framework in general, is because it's Python.
- 22:57It plugs in with the whole data science world, trivially.
- 23:00And, you know, I'm always kicking myself thinking, gosh, I want to be doing more data science.
- 23:05But fortunately, when I do get the chance to, you know, play around with Pandas, and I need to display the result of data, making it work with Django is easy.
- 23:16I know people in the Node and Rails world who, you know, when they work with tools like Panda, they've got to jump through, you know, there's extra hoops to make it happen.
- 23:26And thankfully, the Django and Flask and Pyramid world, we don't have to worry about it.
- 23:32Yeah, that is pretty interesting that, like, so much of the machine learning stuff and the data science stuff is in Python.
- 23:38And that just means, you know, you can, you know, we think about full stack programming already, right?
- 23:44This is another level, right?
- 23:45Another aspect of, like, you can just plug machine learning straight in, and you don't have to basically do anything, right?
- 23:50Just call it.
- 23:51Yeah, it's an exciting time to live.
- 23:53Let's just put it that way.
- 23:54Yeah, I kind of feel the same way every day I wake up.
- 23:56I'm like, it's so amazing to be alive.
- 23:57Let's go.
- 23:58What else are we going to do?
- 23:59Oh, another thing I want to bring up about Django, and this is one of my favorite selling points, is its security.
- 24:05You know, if you follow Django's best practices, odds are you're going to be in a good place.
- 24:11If you don't have debug equals true in production, you know, odds are you're going to be not having to worry about people penetrating your system.
- 24:21And there's also a pretty large and dedicated security team that works.
- 24:27I mean, the core Django team has a security group that's large and dedicated.
- 24:32In fact, every version of Two Scoops of Django that we've released, the security sections have been vetted extensively by the security group.
- 24:44It's, yeah, we spend more time on that, the chapters and appendices in the book for security than any other place,
- 24:51just because they go over it with such a fine tooth comb.
- 24:56That's really great to hear.
- 24:57I mean, that's one of the things that definitely can keep you up at night.
- 25:01I mean, or if you're doing this for your company, it can be dramatic when that kind of stuff slips.
- 25:07So they do have such a great attention to detail on the security space.
- 25:11That debug equals true problem in production, that is not good.
- 25:17There was some security researcher that had, like, gone through and realized that they could actually pull the AWS secret keys out of a bunch.
- 25:27And Stripe keys, MailChimp key, you name it.
- 25:30The API keys that are stored, basically, in memory were things that you could just go scan and pull out of these things because they're running the debug tools.
- 25:39Absolutely.
- 25:40So a little bit of background.
- 25:43Someone went to, I think they went through various Heroku apps or powered apps and nothing against Heroku.
- 25:51But Heroku is a common target for people first learning how to deploy Django because at the basic level, it's free.
- 25:58And it's simple, right?
- 25:58There's like, you don't have to configure Nginx and uWSGI or GUnicorn.
- 26:02You just like push app.
- 26:04Right.
- 26:05And I think Python Anywhere as well.
- 26:07And they found 28,000 instances of people's Django projects.
- 26:13And most of them were probably just simple tutorial applications where they set debug equals true.
- 26:18And it doesn't matter how secure your framework is.
- 26:22If you have it in debug mode in production, it's, you know, it's game over.
- 26:26There's nothing that can be done.
- 26:28That's your fault.
- 26:29That's not the framework's fault.
- 26:30It's somewhat of an education thing.
- 26:32But I don't know.
- 26:33Maybe you could do it.
- 26:35Maybe you could somehow deal with this.
- 26:36But nothing really comes to mind unless there's just like a huge scary box that absolutely appears on every page.
- 26:44Then probably it would help.
- 26:46But, you know, it's a tradeoff, right?
- 26:48Yeah.
- 26:48Yeah.
- 26:49Well, definitely be sure to follow the security best practices.
- 26:51But once you do, then it's all good.
- 26:53All right.
- 26:53So one of the things I said when we got started was the Django 2 announcement is a really big deal.
- 26:59And I want to kind of set the stage for that before I ask you more about it.
- 27:03A while ago, two years maybe, there was more of a debate about Python 2 versus Python 3.
- 27:10And are we going to cross that chasm?
- 27:12And I feel like we're kind of on the downward.
- 27:14Like we're coasting downhill to like wrap that up, even though it's going to become really bumpy around 2020.
- 27:21It's going to be real interesting.
- 27:22Very bumpy.
- 27:24Very bumpy.
- 27:24But it's going to be the bottom of the hill and the bumps are going to be there.
- 27:27Anyway, I think we're kind of over the debate.
- 27:30But one of the things that was really interesting around Python 3 a little while ago with Django was they switched the default recommendation and just the tutorial steps of using Python 2 to using Python 3.
- 27:44And that made a really noticeable difference in the PyPI download statistics for Python 3 usage.
- 27:50Oh, I didn't know that.
- 27:51Yeah.
- 27:52Basically, the tutorial switched to say, here's how you get started.
- 27:55You type Python 3, this, da, da, da.
- 27:56And that made like a 5% difference in the usage.
- 28:00So the reason I bring this up is that that is such a dramatic difference that even a small change has.
- 28:07And now being Python 3 only, it's just going to take it to another level.
- 28:11And so I think Django is one of these things that stands out in the community as really having power to move that needle on the Python 2 versus Python 3 debate.
- 28:22You mentioned pandas before.
- 28:24They're also going Python 3 only.
- 28:25So we're seeing this in other more than just Django.
- 28:28But it's a big deal, right?
- 28:30Okay, so let me give you some background so I can give you my example.
- 28:34I maintain or I help maintain or co-maintain a number of packages.
- 28:39And some of them, for example, Cookie Cutter, which I'm one of the maintainers on,
- 28:43we maintain every supported version of Python and some unsupported ones across every major operating system.
- 28:51And doing that is challenging.
- 28:54It's possible.
- 28:55And I'm not going to say it's easy because sometimes things just suddenly break and, you know, you have Unicode issues and stuff like that.
- 29:04And when you get to move a package to just one version, major version of Python, like from 2 to 3, it's wonderful.
- 29:14It's bliss.
- 29:15You get to remove tons of special code.
- 29:18And I know there's libraries like 6 and Futures that makes it easier.
- 29:22But trust me, you get to get rid of tons of code.
- 29:26You have logic trees that you hope are being tested properly until someone reports an edge case.
- 29:33All that goes away.
- 29:34So it really lowers the amount of effort you have to put in to maintain a project.
- 29:41So what this means is it's not an immediate effect for Django to move to Python 3 besides, you know, the increased downloads on PyPI.
- 29:50Right.
- 29:51Because it ran in Python 3 already.
- 29:52It's not like, oh, now it supports Python 3.
- 29:54It just drops support for the old one.
- 29:56Yeah.
- 29:56And the thing is, it's not that you'll necessarily see more features.
- 30:01But what you may see, because maybe something's pretty feature complete, but what you may see is maintainers having more bandwidth to answer questions, to make sure that tasks are actually testing what they're supposed to be testing.
- 30:17So the end result is, even if you don't see more features in a project that's Python 3 only, it will be more polished.
- 30:26It will run better.
- 30:27The maintainers will be able to be more responsive simply because they have less work to do in maintaining compatibility over multiple versions.
- 30:36As one of the maintainers of Cookie Cutter, I can tell you we cannot wait until we only have to maintain one version of, one major version of Python.
- 30:46Do you have plans for that?
- 30:47In 2020, when that happens?
- 30:48Eat a lot of cookies.
- 30:50We're going to celebrate with cookies.
- 30:53I guess that's the most formal plans that we have right now because that's still, you know, two years away.
- 30:59I'm really glad to hear Guido come out and say it's January 1st and put an actual date on it because it was within a year range.
- 31:05There's a lot of speculation.
- 31:05Oh, so it is January 1st.
- 31:07Okay.
- 31:07I heard that, but I wasn't able to confirm that.
- 31:10Yeah.
- 31:10There was some very strong statement that Guido came out and said, like, let's not mince words or, like, be ambiguous.
- 31:17It's going to be end of life.
- 31:19No more support.
- 31:20Period.
- 31:21January 1st, 2020.
- 31:23Oh, wow.
- 31:24Do not expect the core developers to help you even with security.
- 31:26That's it.
- 31:27Like, something to that effect.
- 31:28I mean, that's paraphrasing, but that's more or less what he said.
- 31:31Well, who knows?
- 31:31We might release a cookie cutter enterprise support edition for 2.7.
- 31:37That's right.
- 31:37Because we know that there's a lot of big companies using cookie cutter.
- 31:40And who knows?
- 31:42We know that there's a legacy Django group that has a business plan like that.
- 31:47So, who knows?
- 31:48As a way to kind of lead into the next question, I feel like we've been around long enough to know the whole change in the Y2K era.
- 31:59Like, I remember when it was like...
- 32:02I remember that.
- 32:02Do you have a flight on January 1st?
- 32:04You might not be able to go.
- 32:06Like, the computers may be...
- 32:07Like, people were, like, legitimately, like, we don't know what's going to happen.
- 32:10And I think January 1st, 2020 is a little bit like that.
- 32:14It's not going to be like the code is going to stop running.
- 32:17But people who, you know, as soon as there's, like, some sort of major security issue and the CEO says,
- 32:24I heard that there's this big problem and we kind of use the same software stack, but we're fine, right?
- 32:29Like, no, we're actually not fine because you didn't fund us upgrading to Python 3.
- 32:32Consultants will be hired at whatever rate they want right then, right?
- 32:36So, there's going to be a definite...
- 32:38Oh, yeah, that's true.
- 32:39Yeah.
- 32:40It's not going to be quite on the single day.
- 32:43But there's going to be some serious consulting for people that know how to upgrade Django apps, upgrade Python in general, right?
- 32:50Right.
- 32:50So, what Mike is talking about here is after 2000, you had some of it leading up to it, but after the year 2000, COBOL developers, you know, the old programming language COBOL, which still drives a significant part of our banking system, suddenly became the hot thing.
- 33:08And they, you know, they're pulled out of retirement and they were making, you know, salaries, crazy, crazy salaries.
- 33:15And I remember thinking, gosh, maybe I should have learned how to program in COBOL at the time.
- 33:20What he's insinuating is some of this will happen.
- 33:23And I know that there are some industries where the software, like, for example, the visual effects industry, last I heard, they were still very much stuck on like Python 2.5 or 2.6 that runs inside their commercial software that they use.
- 33:40And so, we'll see what happens with them in the year 2020.
- 33:44Will they upgrade or we'll see.
- 33:46Yeah, we'll see.
- 33:47But it's going to be an interesting time.
- 33:49The next question I wanted to ask you is who should be upgrading to Django 2?
- 33:54First of all, there's just a couple of new, really nice features.
- 33:57Do you want to touch on those first?
- 33:58Sure.
- 33:59Actually, what's interesting, the change from Django 1.11 to 2.0 was minor.
- 34:04It was less than the change from 1.10 to 1.11, which is kind of interesting, especially for someone who published a book called Two Skips of Django 1.11.
- 34:14Because we have people coming to us and saying, oh, well, it still worked with 2.0.
- 34:19And it's like, yeah, 98% of the book still works.
- 34:22But there are two little things that are kind of nice.
- 34:26One is the routing system for URLs is very Flask-like now, the default one.
- 34:32That's easier for beginners or for people who just don't like to play around with regular expressions like I do.
- 34:38It always struck me as a little bit contrary to the zen of Django to have regular expressions in there.
- 34:47Because Django is all about helping you make things easy and make these choices.
- 34:51And, oh, by the way, here's this crazy, super hard syntax.
- 34:54If you're not a programmer, you put that here.
- 34:56You're like, whoa, why is this not just like clearly the name, right?
- 35:00Like Flask or Pyramid or whatever.
- 35:02So the contrarian in me says, what's wrong with regular expressions?
- 35:07But the realist in me agrees with you.
- 35:10Yeah, yeah.
- 35:10I mean, think of the marketing person who decided they're going to learn a little programming so they can get some interactive site.
- 35:15Like that person is going to have a hard time with regular expressions.
- 35:18Yeah, I can't disagree with you there.
- 35:21The other thing is the admin interface that comes with Django.
- 35:25That's now mobile friendly by default.
- 35:27So you don't need to install another package to make that work.
- 35:30So that's really nice, especially since often when you're accessing the admin, you're doing it from your phone, trying to fix something, you know, in the middle of the night from bed.
- 35:41You get woken up by like a pager thing.
- 35:44Okay, we'll fix this.
- 35:45Or on vacation.
- 35:47Or on vacation when you have a slow connection.
- 35:49So yeah, so those are the two significant changes or what I consider the two significant changes.
- 35:55And as you can see, they're pretty small.
- 35:57Again, the big switch with 2.0 is going to Python 3 only.
- 36:03And then, you know, that leads in the question of why shouldn't you move to Django 2.0?
- 36:09And there actually are a few reasons.
- 36:11Django 2.0 is a standard release for Django.
- 36:15And that means it is supported by the core team for less than a year.
- 36:20Whereas Django 1.11 is a long-term support release, which means it's going to be supported until at least April 2020.
- 36:29Although we'll see what that means with Guido dropping support for Python 2 on January 1.
- 36:36Maybe it'll truncate it a little bit.
- 36:38Yeah, who knows?
- 36:38Yeah.
- 36:39So in fact, what that means is Django 1.11 is going to be supported longer than 2.0 and 2.1.
- 36:47So if you have an organization that moves slowly.
- 36:50Right.
- 36:51So you'll be forced to upgrade on 2.0.
- 36:54Yeah.
- 36:55Yeah.
- 36:55If you have an organization that moves slowly, sticking with the long-term support version, it can be a really good thing.
- 37:01And at NASA, we are always long-term support.
- 37:04So that's why to stay on 1.11.
- 37:06Are there companies that have like LTS only sort of guidelines?
- 37:10Like do not use a version of Linux that's not LTS?
- 37:13Do not use these packages that are shorter term and like always just stay on the LTS version?
- 37:18Or is it just a culture thing?
- 37:19I don't know if they have formal policies or not.
- 37:22I know at NASA, we didn't have a formal one or at our center.
- 37:25And it might have changed there because with the, you know, advance and DevOps and deploying stuff to the cloud, things are easier, at least at NASA.
- 37:35But I know that there are certainly organizations that we've dealt with where because they know, you know, the engineers and developers know that upgrades just take a long time to implement like a major upgrade.
- 37:49They rather stay on an LTS and then get the minor patch updates.
- 37:55It's why Red Hat and other organizations do long-term support releases is just because the larger a group gets or the less funding it has for a project, the more likely it is to stay on a particular version of a project.
- 38:09Yeah, that makes a lot of sense.
- 38:11So would you recommend that people maybe start on Django 1.11?
- 38:15Or is it if you're starting a new project, it's 2.0 for sure?
- 38:19I say that 95% of people should be starting on the most recent version of Django, for which our book still certainly absolutely applies.
- 38:29And then, you know, upgrade as soon as, maybe not as soon as the next version of Django comes out, but like the first patch release, right?
- 38:38Because that's when all the secondary packages and projects update.
- 38:42It's just like that with Python, right?
- 38:45Like as much as I can't wait till 3.7 comes out for Python, I'm going to probably wait a little bit before start coding in it because I know that there are packages that I use that won't be supported yet.
- 38:57As much as I like to be on the bleeding edge of things, I don't have that luxury.
- 39:03You also don't want to wake up in the middle of the night because it's leaking memory or some weird thing like that, right?
- 39:09Yeah.
- 39:09So if you look at the dates, like Django 1.11 is scheduled to be supported till April 2020.
- 39:16Django 2.1 is till December 2019.
- 39:20So that's like right on the cusp of the Python 2 cutoff anyway.
- 39:23So there's not a huge difference like currently.
- 39:26No.
- 39:27At four months, right?
- 39:28So that's not, I don't know, if I was starting on new, I would definitely go for the 2.01.
- 39:32But yeah, it's just me, I guess.
- 39:34I always try to do the latest and greatest.
- 39:35Yeah.
- 39:36So another recommendation you have is like, you probably shouldn't move to 2 if you can't run on Python 3, which is obviously like, it's not, you shouldn't.
- 39:45You cannot move to 2 if you cannot run on Python 3, right?
- 39:49Yeah.
- 39:49So in fact, I really try not to make fun of, you know, other software developers.
- 39:55We have a challenging job.
- 39:57But sometimes on some of my projects, open source projects like cookie cutter Django, someone will say, hey, it's not working.
- 40:03And then they show the stack trace and it's clear they're running 2.7.
- 40:08And it's like, well, you're running Django 2.0 with Python 2.7.
- 40:13It's just going to break.
- 40:14Not intended to work that way.
- 40:16But we all make mistakes like that.
- 40:17So it's, you know, like I said, I shouldn't make fun of people.
- 40:20Well, I think part of it is like, we need a little bit more help from the operating system folks to make this a little bit smoother, right?
- 40:28Like on my Mac, if I'm just a person, I know I want Django and I know Django uses Python.
- 40:33I type Python and that comes up with a program that does a thing.
- 40:36Like I might try to type pip install Django and just run it, right?
- 40:43Like there's nothing along that path that's like a big warning slide.
- 40:46Like you're set up for failure, but if you don't know, oh, there's this thing where there's a Python 2 and a 3.
- 40:53They're incompatible.
- 40:54You don't have 3 by default, right?
- 40:57I mean, Linux is starting to fix the problem because they're starting to default to Python 3.
- 41:03Windows ironically fixed it by not supporting it at all.
- 41:07So you have to go seek it out.
- 41:08Why would you seek out the old one?
- 41:10I actually think that's kind of a good thing.
- 41:12Yeah.
- 41:12And then Mac comes with just the old one.
- 41:14What do you think about all that?
- 41:15Like I said, I kind of, I mean, I know with a POSIX operating system, there is no choice.
- 41:21I think they do need system Python just to run.
- 41:24Operating system experts can correct me there.
- 41:27So I don't think taking Python out of OS X or Linux is a solution.
- 41:32But in some ways I am envious of the Linux world or not the Linux, the Windows world where
- 41:38to run Python, you have to install fresh installation.
- 41:42And, you know, maybe the answer is with some of these projects of complexity, such as Pandas
- 41:50or Django or whatever is, you know, maybe we could put in something saying, oh, you're running
- 41:56the system Python.
- 41:57We're not going to let you do that.
- 41:58You have to go and install a new version of Python.
- 42:01And I don't know how realistic that is.
- 42:04I'm just not, I just don't know enough on the subject.
- 42:07But having seen beginners stumble through that again and again in the Python world, I definitely
- 42:14hear that.
- 42:15That would be kind of ideal if we forced people to install an external version of the language.
- 42:21Right.
- 42:21Or I understand the system needs it, but does it have to default to Python?
- 42:29Could it be Python 2 is the thing that is Python 2 and Python is Python 3, right?
- 42:34Like it, I feel like they could somehow patch that up and kind of make things more or less
- 42:39hang together.
- 42:39Probably would take some work.
- 42:40My reading is it's probably just not a priority, at least in the macOS world.
- 42:45In the operating system world, I just don't see them making it a priority.
- 42:49They've got other things on their plate, either for financial reasons or bandwidth reasons.
- 42:54But I wonder, you know, is it possible when you run a library like Pandas, for example, can
- 43:01we detect whether or not you're running the system Python?
- 43:04And if so, throwing that flag down saying, hey, you need to go to python.org or install
- 43:10Wakanda rather than forcing people to learn the hard way that screwing their system Python
- 43:17is going to be really painful.
- 43:18Yeah.
- 43:18I mean, probably the error you get the vast majority of the time is like this particular
- 43:23method or this attribute, like an attribute error or something to that effect or an import
- 43:27error.
- 43:28And that means nothing to people.
- 43:29It's just like, oh, it's broken.
- 43:30Right.
- 43:31But if you got a wrong version of Python error.
- 43:33Exactly.
- 43:33That actually would go a long ways towards, oh, I have the wrong version of Python.
- 43:38Not like, oh, it's broken.
- 43:39It just doesn't work.
- 43:40Wow.
- 43:40That's a really awesome idea, Mike.
- 43:43I wonder what we can do with it going forward.
- 43:46It's not hard.
- 43:48Right.
- 43:49Just check system version.
- 43:51Right.
- 43:51But it's it's seems like just a little bit of communication.
- 43:55But yeah, I I hear the problem.
- 43:57I would prefer that the operating systems come with modern Python if they're going to have
- 44:01it.
- 44:01But who knows what what could we do?
- 44:03This portion of Talk Python To Me is brought to you by ActiveState.
- 44:09ActiveState gives you a faster way to build and secure open source runtimes from your first
- 44:14line of code through to production.
- 44:15Every second you spend building your Python distro or trying to secure your Python programs
- 44:19is less time spent doing the work you love.
- 44:22You've got better things to do than trying to resolve dependencies or making sure that you
- 44:25tick off all security boxes when you ship to production.
- 44:28Standardize on your Python builds so you can have less friction in the development cycle and
- 44:33you can deliver apps faster.
- 44:34You can also get a unique server side way to verify your Python applications at runtime.
- 44:39Bake security right into your code without impacting performance.
- 44:42Go faster.
- 44:43Spend more time doing the work you love and comply with your enterprise security needs.
- 44:47Try ActiveState and see why it was chosen by IBM, Microsoft, NSA, Siemens, PepsiCo and more.
- 44:53Join millions of developers who trust ActiveState to build their open source language distros.
- 44:58Visit talkpython.fm/ActiveState for a special offer.
- 45:01That's talkpython.fm/ActiveState.
- 45:04Greetings from the expo booth here at PyCon.
- 45:07I just want to add one quick thing to that spot you just heard.
- 45:10The ActiveState folks just had a really cool announcement.
- 45:13So if you're here at PyCon, drop by their booth and ask them about it.
- 45:18They'd love to tell you about it.
- 45:19All right.
- 45:19Hope you enjoy this episode.
- 45:20And if you didn't make it to PyCon this year, you owe it to yourself to do it next time.
- 45:27All right.
- 45:27So generally, you're thinking the advice is, unless you have some kind of major blocker,
- 45:32one of these edge cases we talked about, it's all about Django too.
- 45:35It's all about Django too.
- 45:36Always go forward.
- 45:38Is there more to it than pip install dash capital U Django to upgrading?
- 45:44Or do I need to change configuration files or anything like that?
- 45:47In a perfect world, it's really easy.
- 45:49You just do pip install dash U Django, then run your tasks and deploy.
- 45:54But the Django world has a large and comprehensive ecosystem of packages and products.
- 46:01You know, Audrey and I had a part in building and maintaining it for a long time.
- 46:06We've stepped away in the past, I guess, two years.
- 46:09So sometimes your auxiliary packages don't work.
- 46:13And this is why it's so critical to have tests.
- 46:17Because, I mean, you know the drill.
- 46:19You update a package and then you run your tasks.
- 46:22And if something breaks, then you see if it's something in your code that's breaking or if it's something in a third-party package.
- 46:29And then in which case, maybe you need to update that.
- 46:32And tools like pyup.io, which is created and maintained by my good friend, Jan Eskabauer, that certainly makes it easier.
- 46:39But you still have to run those tasks.
- 46:42And this is, you know, my favorite reason to include tests.
- 46:46It's less to find bugs and more to make upgrades for versions of Python and Django and other tools easier.
- 46:52It's more the smoke test rather than the nuanced unit test, right?
- 46:55Like, does it generally hang together?
- 46:57Exactly.
- 46:58So fortunately, what I found is upgrading from 1.11 to 2.0 is pretty easy.
- 47:04There is none of the, from 1.10 to 1.11, I think it was, the way that Django handled cross-site request forgeries was changed.
- 47:16And if you had a busy, you know, very, very busy project with millions of users, if you deployed it and all of a sudden for a few minutes, everybody's forms stopped validating, that made upgrades or upgrading from 1.10 to 1.11 challenging.
- 47:32But fortunately, with going to 1.11 to 2.0, for us, it's been really trivial.
- 47:38It's been really sweet and easy.
- 47:40So I think that was kind of intentional when they went from 1.11 to 2.0 and the big change being the version of Python or that it doesn't support 2.7 is just to keep that advance easier.
- 47:54Yeah, it's clever to make that there.
- 47:56So that sort of decision to say the way people perceive it, the change is going to be actually really small.
- 48:01So encouraging people to get on that new track that's Python 3.0 only is really not scary.
- 48:07It's not like, oh, we've changed some settings, config format or something, and you've got to make sure you change that, too.
- 48:12For us, at least, it's been very easy.
- 48:14And this doesn't just apply to Django with Pandas or other tools.
- 48:19This is one that, like I said, is a great justification for having tests is that it makes these upgrades easier, especially as we move to the Python 3.0 only world of the future.
- 48:29Yeah, just create a new virtual environment, check it out again somewhere else, do the upgrade, run the requirements, do the upgrade, run your tests.
- 48:39If that works, you're probably good, right?
- 48:41You don't have to break what you have sitting on your main desk, right?
- 48:44Absolutely.
- 48:44Nice.
- 48:44So what's the future, Django?
- 48:46I'm not a core developer, so people often think that I am.
- 48:50So I don't really know too much about what's coming.
- 48:53When I have looked at the roadmap, there hasn't been anything super concrete that's changing.
- 49:00But again, I'm not really in the loop, and I don't go to that many Django-specific conferences, so I just don't know.
- 49:08There are some things that I would love to see, though.
- 49:12Deployment is still kind of a pain.
- 49:15I know there's services like Python Anywhere and Heroku and now Zappa that make it easier, but I've always wondered if there's a way to make those hooks a little bit better and easier.
- 49:27And also, we're in a world of data science, and for better or for worse.
- 49:34And having Django integrate better with those tools, I think, is something we're going to see more of in the future.
- 49:42There aren't that many huge and easy to lose, not huge, I guess that's the wrong term, but comprehensive libraries with good documentation on how to integrate, pulling data out of a server, running it through Pandas or PyTorch or whatever, and then displaying that with Django.
- 50:00There's the odd blog post or Stack Overflow answer, but I'm guessing in this year we're going to see that start to change.
- 50:09Because part of data science is displaying your data, displaying the results.
- 50:14And you can crunch numbers all you want.
- 50:18You can data wrangle.
- 50:18You can do all that stuff.
- 50:20But if you don't display your data, especially with a large project that needs to be able to do this for its end users, who's your customer?
- 50:29The sales team?
- 50:30That may not be enough for you.
- 50:31For sure.
- 50:32And we've got things like Jupyter, JupyterLab, and there's a whole explosion of notebook solutions.
- 50:38But in the end, maybe you want to show it, like you said, not publish a paper of data to your sales team, but give them dashboards within the app and things like that.
- 50:47Yeah.
- 50:47And not to bring up politics, but I don't know too much about the whole thing with Cambridge Analytica.
- 50:55But from what I'm gathering, part of what they were giving were reports to end users.
- 51:01And, you know, while that might have been done for the wrong cause and the wrong purpose, there's a sales opportunity for you, which is for consultants or companies around the world, which is you have this framework, Django.
- 51:15You have all these machine learning and data science tools that are accessible via Python, providing a means for publishing that data is part and parcel in what we do as engineers.
- 51:26Yeah, for sure.
- 51:27And making that easier and beautiful, that'd be awesome.
- 51:29All right.
- 51:30Well, let's go ahead and actually have one more question before we drop off, Django, that I wanted to, I threw here at the end, I want to ask you.
- 51:36So one of the really powerful things that we have in Python 3 these days, and it started 3.4, 3.5, but really came into its own in 3.5 with async and away is the whole asynchronous programming model.
- 51:49And that's like largely missing from the main web frameworks, right?
- 51:56Like, just you can't throw an async Jenga view up there or an async flask view or an async pyramid view or whatever, right?
- 52:04And a wait on various things.
- 52:06Do you see stuff like that coming?
- 52:08Do you think it's important?
- 52:09I think it's critically important.
- 52:11One of the things is when you play with a language like modern Python outside of the web or with Go or with JavaScript is async is just getting easier and easier to implement.
- 52:25It's more straightforward.
- 52:28And the issue, though, with Python web frameworks is that this is a very hard problem, be it Django, Flask, Pyramid, or whatever.
- 52:37They're all based on a WSGI.
- 52:38They're all based on WSGI.
- 52:40And WSGI follows a very precise request and response cycle.
- 52:45And while Andrew Godwin has been working on channels for Django, which provides an asynchronous system and it's powered by asyncio under the hood.
- 52:56But they're all these like we have Quart for Flask, which is really nice.
- 53:00But they're all like, we're going to take this and make a copy of it.
- 53:03And it'll be really, really close to the thing that you want to have.
- 53:07Right.
- 53:07Django, Flask, whatever.
- 53:08Right.
- 53:09But it's just they have not made their way into these major, the actual official major frameworks.
- 53:13I think that Django is too resistant to breaking backwards compatibility that I don't see it happening in the next couple of years, which I think is kind of a shame.
- 53:24You know, I think Andrew Godwin should just be committing right to core, right to the master branch.
- 53:30Yeah.
- 53:31The stuff he's doing is awesome.
- 53:32I had him on the show quite a while ago and people can go back and listen to the whole episode on that.
- 53:36Yeah.
- 53:37I think Flask's API is pretty stable, but there are async clones for Flask.
- 53:41I think there's Sanek.
- 53:42There's API star.
- 53:44There's a bunch of these things.
- 53:46But even though these things exist, deployment isn't really that straightforward.
- 53:52I know that you can deploy a channels application on Heroku and I'm pretty sure you can probably do it on Python anywhere.
- 53:58But it's not the default operation.
- 54:01It's not for people who are just new to the system.
- 54:04It's an advanced topic.
- 54:06And I think that's a shame because the way of the world is async, right?
- 54:11That's the trend.
- 54:12And it's not a trend.
- 54:14It's the way things are going.
- 54:16Now, Andrew Godwin has his own specification that he wrote or actually created.
- 54:22It's not his specification called ASCII, which is asynchronous service gateway interface.
- 54:27But until I think we have a long way, I think WSGI is so entrenched in our Python world that it's really hard to break out.
- 54:38And I think it's a shame.
- 54:39And I think if someone came up with a business model to get around that, they would make a lot of money.
- 54:45I know I would use that system in a heartbeat.
- 54:48As much as I like using EC2 and playing around Zap on Lambda to be able to do asynchronous easily with easy deployments without having to stand up my own server or use a platform as a service system that's super integrated in itself.
- 55:06For me, that would be awesome.
- 55:08I'd love to see something like that.
- 55:09But I think that's not going to happen for several years.
- 55:13Yeah.
- 55:13It's kind of a bit of a chicken and egg kind of blockade thing.
- 55:17But it'll break free.
- 55:18It'll come out.
- 55:19It just sooner would be better.
- 55:21Every time I hear somebody say, oh, we're switching to go for because the performance is better async and whatever.
- 55:27Part of the problem is somewhat self-inflicted.
- 55:30And it could easily be fixed with just a slight, like basically a one function called deep, deep down from process request or whatever it's called to like process async request.
- 55:41And it like kind of cracks loose, you know.
- 55:43But yeah.
- 55:44Okay.
- 55:45Someday we can look forward to the future with async methods and all the major frameworks.
- 55:49Yeah.
- 55:49I can't wait.
- 55:50These creative and powerful.
- 55:52Yeah.
- 55:52Knockoffs.
- 55:53But let's bring those back in.
- 55:55Right.
- 55:56Nice.
- 55:56Okay.
- 55:56Well, let's touch really.
- 55:57We're getting low on time.
- 55:59But maybe just tell us a little bit about your Django book.
- 56:01It's been one of the more popular ones.
- 56:03So you have two scoops of Django, right?
- 56:05Yeah.
- 56:06Two scoops of Django.
- 56:07And it's been out since 2013.
- 56:09We're on the fourth edition, which is kind of awesome.
- 56:13If we do another version, we won't release it until next year, which is when the next time a long-term support version of Django is released.
- 56:22And if we do it, we'll make.
- 56:24You're going to call it two scoops of Django 2?
- 56:262.2.
- 56:26It'll be two scoops of Django 2.2 if we do it.
- 56:29And because it's so much work to do.
- 56:32If you want to inflict pain on an enemy, get them to write a book.
- 56:35And if we do it, we're planning some substantial changes.
- 56:41Like we'd probably have much more, touch a lot more on asynchronous stuff, especially with Python 3.
- 56:48And we'll get to get rid of all of the Python 2 stuff, which will be awesome.
- 56:52Yeah, yeah.
- 56:52That's really cool.
- 56:53So what are some of the core principles from your book?
- 56:55With two scoops of Django, it's a big book.
- 56:58It's 550 pages.
- 56:59But you can boil it down to you want to embrace best practices.
- 57:03Pet bait, good import policies, having tasks, be aware of security, understand your tools, and try to keep your implementation of everything as simple as possible.
- 57:15Because your business logic, no matter what your project is, is never going to be as simple as you think it's going to be.
- 57:22The other thing that we did that really helped with it was have a lot of fun examples.
- 57:28I mean, that's the theme, ice cream, right?
- 57:30Audrey insisted on that.
- 57:32And she did the illustrations.
- 57:35And while she was also doing the illustrations, I need to point out, she wrote more of the book than I did.
- 57:40So I'm the loud one on social media, but she's the more productive one.
- 57:45You don't go to MIT and not know how to write about Python and Django.
- 57:50And of course, there's the ice cream theme.
- 57:52And that ties into the fun examples.
- 57:55A lot of programming books.
- 57:56We've seen a lot of changes since the release of our book.
- 57:59And other books like, you know, Land of Lisp, they've gotten more colorful.
- 58:04But when we first came out, we were like a fresh rock being dropped into the pond.
- 58:10It was kind of awesome at the time.
- 58:11And now we're not so significant, which is kind of sad.
- 58:14A fresh replacement for a few and a bar.
- 58:16Or a spam.
- 58:17I love spam.
- 58:18But yeah, that had gotten very old.
- 58:20That's for sure.
- 58:21All right, cool.
- 58:22So definitely recommend your book.
- 58:24It's a good one.
- 58:24I guess one final thing I want to ask you about, because we were talking before we hit record.
- 58:29You have some good advice for folks is PyCon is coming up.
- 58:32This episode, I don't remember how the timing is going to line up.
- 58:35This is going to be like right around PyCon.
- 58:37It may be the week of PyCon that this comes out.
- 58:40So what's your advice for people getting the most out of that conference?
- 58:43My advice to PyCon is, first of all, you should go if you can.
- 58:48And if you can't go to the one in the U.S. or North America, you should go to your local regional one.
- 58:54And then if you go, don't hang out with your friends.
- 58:58Make new friends.
- 59:00You are there to broaden your horizons.
- 59:02And hanging out with your friends, I know it's easy.
- 59:04And I know you're nervous.
- 59:06I know you're scared.
- 59:07But by making new friends, you're going to broaden your horizons.
- 59:10You're going to learn new ideas.
- 59:11You're going to make new connections.
- 59:13And that is why you are there.
- 59:16And while you're doing that, don't show off how much you know.
- 59:20Instead, ask questions.
- 59:23And yeah, if someone starts to explain something that's super trivial and obvious to you, maybe you've got a PhD in a particular field and it's on your label and someone starts to explain it to you, then yeah, you can start showing off how much you know.
- 59:39But really try to focus on asking questions.
- 59:42Because you're there to learn, not to show off what you know.
- 59:46And I know as someone who has gone to conferences and hire people, I'd rather hire someone who is eager to learn and find out new things than a know-it-all.
- 59:57I definitely second that.
- 59:58Yeah, for sure.
- 59:59And then if you have been to a conference before or if it's your first one, volunteer to help in a session.
- 1:00:06If there's a volunteer process, get involved.
- 1:00:09And again, the reason is you're there to make connections.
- 1:00:13You never know who is going to be there helping out with you.
- 1:00:17I've certainly made some life-changing differences in my career by volunteering and just happening to meet that right person.
- 1:00:26And so that's really important.
- 1:00:29But overall, just try to break free of the patterns that you have.
- 1:00:33And if you're worried about looking like an idiot, don't.
- 1:00:38Because people will forget you.
- 1:00:39If you do something that's embarrassing and you think it's embarrassing, but most people won't really care.
- 1:00:46They'll be like, oh, whatever.
- 1:00:47It's just another overeager conference goer.
- 1:00:51I know I've done some things that are really embarrassing and no one remembers but me.
- 1:00:56Like, I can assure you that.
- 1:00:58And I'm not talking about offensive things.
- 1:01:00Like, don't be offensive.
- 1:01:01But if you happen to start explaining to this middle-aged guy, you know, that Python 3 is going to be taking over on January 1.
- 1:01:11And then someone points out to you that's Guido Van Rossum.
- 1:01:14You know, he's not going to remember that.
- 1:01:16In fact, he would probably appreciate somebody coming up and saying that to him.
- 1:01:20Yeah, you're not.
- 1:01:21It's going to be okay.
- 1:01:22Just break free of your normal habits and broaden your horizons.
- 1:01:27Good advice.
- 1:01:28One thing about PyCon, at least PyCon US, because it's so large, that there's an opportunity to tie all three of those suggestions up into one quick and easy thing.
- 1:01:37A lot of conferences have people on the stage.
- 1:01:40There's one track or something.
- 1:01:42There they have the open sessions.
- 1:01:43And so you can volunteer by proposing and kicking off an open session.
- 1:01:49Your friends may not come.
- 1:01:51And you have to ask questions because there's no presenter.
- 1:01:54So it's all about sitting there and having a conversation.
- 1:01:56So I definitely recommend people embrace the open session side of things.
- 1:02:00Open space, whatever they call it officially.
- 1:02:02Because that's something that's not recorded.
- 1:02:05It's only a live experience.
- 1:02:07And it gets you involved.
- 1:02:08Absolutely.
- 1:02:09Nice.
- 1:02:09All right.
- 1:02:09Well, we're just about out of time.
- 1:02:12But before we call it a show, let's ask you the two questions.
- 1:02:16So if you're going to write some Python code, some Django code, what editor do you use?
- 1:02:20So I run and I have a 2011 MacBook Air.
- 1:02:24And so an IDE like PyCharm is just going to break it.
- 1:02:29It worked several years ago, but it's not going to work now.
- 1:02:33So I just use Atom because it runs and it runs fast these days.
- 1:02:38And also if I need to install it on a new machine, as much as I like Sublime, what I like about Atom is I can just install it and go.
- 1:02:46Because we have a couple test machines for Windows and other operating systems that I don't use that often.
- 1:02:51And I can just get Atom going in about 20 minutes.
- 1:02:56It's something that's always there and you don't have to change depending on where you are.
- 1:03:00That's pretty nice.
- 1:03:01And I don't need to learn arcane commands like with Vim or something else.
- 1:03:05Exactly.
- 1:03:05Exactly.
- 1:03:06I'm with you on that.
- 1:03:07So notable PyPI package?
- 1:03:09So I'm going to list two.
- 1:03:10I know we're short on time.
- 1:03:12The first one is Black, which is the uncompromising code formatter.
- 1:03:16And it's awesome.
- 1:03:18I'm replacing PyFlakes and all these other tools on my project with it.
- 1:03:22And the reason why is because I cannot keep, this is my dark secret, I cannot keep single quotes and double quotes from getting into my code.
- 1:03:30And Black just fixes all of that.
- 1:03:32And no one complains or yells at me.
- 1:03:33Oh, it fixes that.
- 1:03:34That's pretty interesting.
- 1:03:35Yeah.
- 1:03:36So we're trying to figure out on our projects how to get it to run and clean stuff up the way we want.
- 1:03:44But yeah, Black is awesome.
- 1:03:46And comes in any color you want, as long as it's black.
- 1:03:48Exactly.
- 1:03:49And the guy who founded it, Rikash Langa, he's a friend of mine.
- 1:03:52But that's not why I use it.
- 1:03:54Well, maybe a little bit.
- 1:03:55That's why I noticed it.
- 1:03:56But it's Black is awesome.
- 1:03:58Okay, cool.
- 1:03:58And then another one's close to home for you guys, right?
- 1:04:00Yeah, that's Cookie Cutter because, well, packaging.
- 1:04:04And it's our most popular project.
- 1:04:07It's got over 7,000 GitHub stars.
- 1:04:09There's a lot of Fortune 500 companies who use it, which is kind of flattering in government organizations.
- 1:04:16Whenever I want to ego trip, I just go into GitHub and search for Cookie Cutter packages.
- 1:04:22Yeah, there's a bunch now.
- 1:04:23It's really cool.
- 1:04:24Yeah.
- 1:04:24Nice to see that doing well.
- 1:04:25Okay.
- 1:04:25Awesome.
- 1:04:26Yeah, I definitely recommend Cookie Cutter as well.
- 1:04:28A lot of the web frameworks are starting to adopt it as the way to scaffold up the apps as well.
- 1:04:33Pyramid went all in on that.
- 1:04:35I don't know about Django.
- 1:04:36They're not using it, are they?
- 1:04:37No, but there's a lot of templates for building Django projects that use Cookie Cutter.
- 1:04:43Right.
- 1:04:43There's independent templates that you can just, you know, Cookie Cutter or whatever the link is and create your Django project, right?
- 1:04:49Exactly.
- 1:04:50Yeah, nice.
- 1:04:50All right, final call to action.
- 1:04:52People are excited about Django 2.
- 1:04:54Dropping that Python 2 aspect.
- 1:04:56What do you recommend for them?
- 1:04:57Final call to action.
- 1:04:58Use Django 2.0, the most recent version of Django, if you can, and buy our book because even though it says 1.11 on the label, it still applies.
- 1:05:08That's awesome.
- 1:05:08And of course, your packaging course as well, right?
- 1:05:10Yes.
- 1:05:11It's available in both English and Spanish.
- 1:05:13Although we talked a lot about Django, the course itself doesn't mention or doesn't have anything to do with Django.
- 1:05:20It's Python specific or it's Django free, however you want to call it.
- 1:05:25Yeah.
- 1:05:25Perfect.
- 1:05:28Perfect.
- 1:05:28Perfect.
- 1:05:28So I'll put a link to all that stuff in the show notes.
- 1:05:30Okay.
- 1:05:30All right, Danny.
- 1:05:31Thank you so much for being on the show.
- 1:05:32It was great to chat with you and talk about the web.
- 1:05:34Thank you for having me.
- 1:05:35Yeah.
- 1:05:36Past, present, and future.
- 1:05:37It's going to be a good ride, right?
- 1:05:39Absolutely.
- 1:05:39Yep.
- 1:05:40Talk to you later.
- 1:05:40Bye.
- 1:05:41This has been another episode of Talk Python To Me.
- 1:05:44Today's guest.
- 1:05:45Today's guest has been Daniel Roy Greenfield.
- 1:05:47And this episode has been brought to you by MongoDB and Active State.
- 1:05:51Interested in seeing how web apps are built with Python and MongoDB?
- 1:05:54Register for my webinar I'm doing with MongoDB over at mongodb.com slash webinar slash Python.
- 1:06:00See you there.
- 1:06:01Active State gives you a faster way to build and secure open source runtimes.
- 1:06:07From your first line of code through to production, check it out at talkpython.fm/active state.
- 1:06:13Want to level up your Python?
- 1:06:15If you're just getting started, try my Python jumpstart by building 10 apps or our brand new
- 1:06:20100 days of code in Python.
- 1:06:22And if you're interested in more than one course, be sure to check out the everything bundle.
- 1:06:26It's like a subscription that never expires.
- 1:06:28Be sure to subscribe to the show.
- 1:06:30Open your favorite podcatcher and search for Python.
- 1:06:33We should be right at the top.
- 1:06:34You can also find the iTunes feed at /itunes, Google Play feed at /play,
- 1:06:39and direct RSS feed at /rss on talkpython.fm.
- 1:06:43This is your host, Michael Kennedy.
- 1:06:45Thanks so much for listening.
- 1:06:46I really appreciate it.
- 1:06:47Now get out there and write some Python code.
- 1:06:49I'll see you next time.