Latest / Talk Python To Me / #97: Flask, Django style with Flask-Diamond
Transcript
- 0:00There's a whole spectrum of Python web frameworks.
- 0:02On one end, we have the micro frameworks like Bottle, Flask, and to a lesser degree, Pyramid.
- 0:08On the other, things like Django or even CMSs like Wagtail,
- 0:12which are built on top of Django way in the far end of the spectrum.
- 0:16While this is often positioned as an either-or choice between these frameworks,
- 0:21this week you'll meet someone who's doing a lot to build some middle ground in the spectrum.
- 0:26Ian Dennis Miller, the creator of Flask Diamond,
- 0:30an extension of Flask which brings the good things from Django to Flask's simple and small API.
- 0:35This is Talk Python To Me, episode 97, recorded January 16, 2017.
- 0:55Welcome to Talk Python To Me, a weekly podcast on Python,
- 1:09the language, the libraries, the ecosystem, and the personalities.
- 1:12This is your host, Michael Kennedy.
- 1:14Follow me on Twitter where I'm @mkennedy.
- 1:16Keep up with the show and listen to past episodes at talkpython.fm
- 1:20and follow the show on Twitter via at Talk Python.
- 1:23This episode is brought to you by Rollbar and Hired.
- 1:27Thank them both for supporting the show.
- 1:29Check them out at Rollbar and at Hired underscore HQ on Twitter and tell them thank you.
- 1:37Ian, welcome to the show.
- 1:39Thanks for inviting me.
- 1:40Yeah, I'm really excited.
- 1:41I often feel like we have to make this tradeoff between micro frameworks when we're choosing
- 1:46a web framework like Flask, to some degree, Pyramid, Bottle, things like that, or Django,
- 1:50which has all these cool building blocks.
- 1:52And I think you're kind of here to dispel the fact that that's the choice to some degree,
- 1:56right?
- 1:57I hope so.
- 1:58I think there's room for something that exists somewhere in between, or maybe that can look
- 2:04like one thing sometimes and look like the other thing other times.
- 2:08Yeah, absolutely.
- 2:08So we're going to talk about your project, Flask Diamond, which brings some Django-like features
- 2:14to Flask.
- 2:15But before we get into those, let's get your story.
- 2:18Where'd you get into programming?
- 2:19Yeah.
- 2:20Many moons ago, in, let's see, I guess, sixth, seventh grade, something like that, I made
- 2:29some kind of transition from using the computer basically as a gaming device.
- 2:36And I started experimenting with this weird program I found lurking in the DOS prompt called
- 2:43GWBASIC, which was a basic interpreter that just shipped with DOS.
- 2:48And I actually started off by entering random words into BASIC because I didn't really have
- 2:57a book for it.
- 2:58And the internet didn't exist at the time, at least not the way that it exists now.
- 3:04You didn't want to like gopher for BASIC?
- 3:06Yeah, right.
- 3:07Now, gopher.
- 3:08So, I mean, you know, as a sixth grader, all that stuff was way beyond my reach.
- 3:12But I guess kids just, our time is worth so little.
- 3:16We sit there and we can just pound away at a keyboard.
- 3:19And eventually, randomly, things started working.
- 3:22And it took years, actually, of doing this.
- 3:26But I learned how to program in BASIC.
- 3:28And then as I grew up, I was able to take courses at school.
- 3:35And so that actually accelerated the process dramatically.
- 3:38Yeah, that's really cool.
- 3:39It's amazing that you actually were persistent to do that.
- 3:42That's really quite incredible.
- 3:44Oh, yeah.
- 3:45You must have thought like when you got to a program in a class, you're like, you mean they
- 3:48give you all the stuff you could tell?
- 3:50You just put it together?
- 3:51This is like, nobody's, I could do this.
- 3:53This is easy.
- 3:54I could not believe it when I learned about a for loop.
- 3:58Because I had discovered this.
- 4:00So in BASIC, you can use a go-to expression.
- 4:03And when I put a logic test inside a go-to loop that just kept looping across itself.
- 4:10And when I got that test to break out of the iterator, you know, that was like discovering the wheel or something.
- 4:16And so then when I learned that other programming languages had that built in and they called it a for loop, that just blew my mind.
- 4:26I mean, everything that came with these high-powered languages like C.
- 4:30That was so awesome.
- 4:31Yeah, that's great.
- 4:32Yeah, so you studied in university?
- 4:36Or when you went to school, what level was that that you started taking program courses?
- 4:40I'm talking here about later in high school, the AP or the advanced placement track at the time was in a language called Pascal, which by now has kind of, you know, fallen away into history.
- 4:56But in the course of taking this AP test, I learned this dead language.
- 5:02And the following year, they switched it over to C++.
- 5:06So I retook the course again, still in high school, and learned C++ in the process.
- 5:11And then, yeah, in university, I actually went a kind of different direction and studied cognitive science.
- 5:16But it still has a foundation in a knowledge of certain computer science principles.
- 5:24But that's a pretty different beast.
- 5:26It is pretty different.
- 5:28Although my experience with cognitive scientists is a lot of them have some reasonable programming skills to do their modeling and whatnot with.
- 5:36Yeah, that's been my experience, too.
- 5:37Yeah, cool.
- 5:38So basic, Pascal, C++, how'd you get to Python?
- 5:43I took a very long pit stop in the Pearl universe.
- 5:49After university, I got pretty involved with building web applications and CGI.
- 5:57This was, you know, the early 2000s.
- 6:00CGI was the way to do it.
- 6:02And Apache had a strong connection to the PHP community and to the Pearl community.
- 6:09And I dug really deep with Pearl for years, but found that this was Pearl 5, 5.8, thereabouts.
- 6:19And it really didn't have a good object model.
- 6:22It didn't have inheritance.
- 6:24And a lot of the things that I came to like from statically typed languages, such as, you know, C and Java.
- 6:32And I found that I wasn't able to scale up Pearl web applications as large as I wanted to.
- 6:38Eventually, the chaos just took over and the bit rot.
- 6:42And I watched a number of software projects die in my hands.
- 6:48You know, I loved them so much, but I just couldn't speak to them anymore because my own Pearl was just so backwards.
- 6:53And anyway, I went looking for something that would be an interpreted language, but also provide strong concepts about object orientedness and inheritance.
- 7:05And Python was perfect.
- 7:07And it also had the momentum, the community of the Python, all the extensions and everything.
- 7:14Then the decent documentation made it pretty easy to get started.
- 7:18So I was really attracted because I just needed to make bigger applications.
- 7:22And Python just perfectly filled that space.
- 7:26Right.
- 7:26Just better structure, better packaging, better ability to separate concerns, all sorts of stuff, right?
- 7:32Exactly.
- 7:32Yeah.
- 7:33And I mean, you could do it in Pearl.
- 7:35There was just an awful lot of ritual, literally ritual involved in that stuff.
- 7:41And they just thought through it the right way in Python.
- 7:45I love it.
- 7:46Yeah, I think that's really important.
- 7:47Because a lot of people, when they're comparing languages, they're like, well, I can do this in this language.
- 7:51Or I could do that in that language or whatever.
- 7:53And it's not always about whether it's possible to be done.
- 7:56It's also how much is that part of the idioms of the language?
- 8:00How hard?
- 8:01How do you have to fight the thing?
- 8:03Yeah.
- 8:03Or do you?
- 8:04Yeah.
- 8:04There's a saying that I like, falling into the pit of success, right?
- 8:08So if you design the language and the APIs, right?
- 8:10If you just kind of follow the breadcrumbs, you end up in the right place versus the wrong place.
- 8:16And I think there's a lot of that in the Python, the falling into the pit of success story.
- 8:21So that's really nice.
- 8:22Yeah.
- 8:22Well, and you know, it's kind of like we, you have infinite power with Perl.
- 8:26And it's the kind of thing where you need to stop and ask yourself if you should, you know, like in the first place, do you embrace that?
- 8:35And the people who do become actual wizards and power maybe, well, I don't know.
- 8:43Perl is really powerful.
- 8:45Let's just say that.
- 8:46Yeah, absolutely.
- 8:47I've actually, yes, just following good Python practices like PEP 8, for example, or the Google style guides are great ways to accidentally write better code.
- 9:01I mean, not accidentally, but just due to habit, create code that is so much more valuable.
- 9:07Yeah, yeah, totally agree.
- 9:08Totally agree.
- 9:08So how'd you get interested in the combination of Django and Flask?
- 9:13Like you were obviously doing CGI and Apache stuff with Perl before.
- 9:17So you're already in the web space.
- 9:19Definitely.
- 9:20And I learned Django first because the documentation is so fantastic.
- 9:28They have covered the novice, like the tutorials for the beginners.
- 9:32They've covered all the depth that you would ever need in terms of API documentation.
- 9:37It was just such a great example of how to build a really vibrant community that is able to get up to speed and then live with it for a long time.
- 9:49So I learned Django.
- 9:51I really like it.
- 9:52I thought an awful lot about the model view controller pattern because that generalizes across a whole bunch of different frameworks.
- 9:59But what I came to the friction point that I found was the typical object relational mapper.
- 10:09The Django way of doing it is part of the core library.
- 10:13And I was really attracted to SQLAlchemy just as a good single concern library that just solved the problems with SQL for all time.
- 10:26And so I didn't want to sacrifice the clarity of using an ORM like SQLAlchemy just so that I could have a better web application experience.
- 10:41I just didn't want my object relational mapper to be so tightly tied to my web stack.
- 10:47And so Flask really provided a model that separated those concerns a lot more cleanly.
- 10:53And when I say Flask, I'm also just kind of lumping in the Flask SQLAlchemy extension, which bridges it in a very natural way.
- 11:01So for me, the ability to deal with the database and alone just in terms of SQLAlchemy and set aside the web concerns for a time meant that it would be a powerful enough way of expressing some really strong statements about the data.
- 11:22I have a lot to say about the data.
- 11:25But as I got deeper into scientific computing, that's where my concerns really lay.
- 11:30And I couldn't imagine using Django to perform that kind of work.
- 11:34I definitely don't want to give the impression you can't do these things with Django because I know that you very much can customize it and set it up just the way you want.
- 11:44But I think it also goes a little bit back to that pit of success, right?
- 11:47That's not the first thing that it encourages.
- 11:50It doesn't say bring your own ORM and use it however you want.
- 11:54Bring your own ACP client and do whatever you want with it, right?
- 11:58It's more about these are the building blocks and you build with them.
- 12:02Whereas with Flask or Pyramid, it's like you go through and you pick the type of thing you want to work with, the pieces you want to use across the whole 96,000 packages.
- 12:11And then you put them together however you feel like.
- 12:13And that doesn't work for everyone.
- 12:15But it sounds like it works for you.
- 12:17And that's also the way that I like to work.
- 12:19So I think it's an interesting option.
- 12:21Well, you know, it did and it didn't work for me.
- 12:23I actually started running into trouble with taking Flask and then having the freedom, having the power.
- 12:30Again, sort of thinking about Pearl and wizardry.
- 12:34The ability to glue together absolutely anything that you can imagine can lead you into chaotic projects.
- 12:43I think it's a lot of places where you do things in an idiosyncratic way and suddenly you can't really collaborate about your project anymore because you've done things because Flask let you.
- 12:55I mean, I'm not blaming Flask, but it just requires such discipline to use it in a way that's predictable enough that any teammate could actually, you know, meet you halfway, read your source code, extend it.
- 13:09I'm being a little bit hyperbolic here because I know that there are people out there that are being very successful using Flask in a team context.
- 13:17But I found that I was getting burned by some of the power and I wanted to regularize some of the ways that I was using Flask and make some of those things repeatable, if only because I didn't want to have to start from scratch every single time.
- 13:33As freeing as that is, I just didn't want to do that anymore.
- 13:36Yeah, I do find a lot of times if you've been working in one company or one environment for a long time, you do feel like you're doing the same thing over and over and over again.
- 13:47One company I worked at, I went so far as to build like a new app generator.
- 13:54And it would spit out a new app with logging already set up.
- 13:57We'd have like exception handling services, kind of things like Rollbar before they existed.
- 14:02It would automatically, you know, all that stuff was integrated and you press the button and then you added, you know, where you went from there.
- 14:08Exactly.
- 14:09That is really handy as long as you can tweak and do whatever you want, I suppose.
- 14:13Well, so yeah, that's a whole other can of worms there.
- 14:17Because I kind of think that scaffolds, so there's a whole ecosystem now of Flask scaffolds because the idea of an app generator is actually really attractive.
- 14:27A lot of people have gained efficiencies by automating some of that stuff.
- 14:32And I went down that path.
- 14:35I started using a Python library called Mr. Bob that just takes a template and a Jinja type template and spits out a file structure, like a directory hierarchy with auto-generated code.
- 14:49And what I wanted there then was the ability to keep the app generator alive such that I could then fold back things that I learned in the process of the previous app into the scaffold so that the scaffold evolved along with my other projects.
- 15:07And so actually that's a large part of Flask Diamond is that it is an app generator.
- 15:13It will scaffold an application, maybe kind of like what you were just describing, you know.
- 15:18It has logging already embedded.
- 15:21Well, anyway.
- 15:22Yeah, so tell us about your project.
- 15:23I mean, I think we've sort of found our way to your project in this whole conversation.
- 15:27So the thing that you created is called Flask Diamond.
- 15:31What is that?
- 15:31So Flask Diamond is, I see it as consisting of a couple of important components.
- 15:38So at a high level, Flask Diamond is a batteries-included Python Flask framework.
- 15:46So the batteries-included part means it will do something without you really doing anything at all.
- 15:52So if you pip install Flask Diamond and then you scaffold an app, the app that comes out already works.
- 16:00And everything's in it.
- 16:02So it does have logging enabled and it does have all these features.
- 16:05And, you know, some of these things I might describe a little bit more later.
- 16:10But the batteries included means the Flask extensions are already there and they've already been hooked up in a way that basically makes sense.
- 16:19For a typical case, this is the kind of thing that's impossible to anticipate everybody's individual project considerations.
- 16:27So you want to get kind of a happy medium between providing something that actually does something kind of neat without any configuration.
- 16:36And it doesn't ideally have too much bloat in terms of getting in the way of you configuring it for however your project is going to deviate from whatever the defaults are, whatever the opinions are.
- 16:50Right.
- 16:50The more opinionated you make it and the more features you add to it, kind of ironically almost, I suspect, means the fewer people who are interested and enjoy it.
- 16:59Right.
- 16:59Yes, I think so.
- 17:00Because if you're like, oh, it needs logging.
- 17:02Most people are like, yeah, logging is good.
- 17:04Oh, it also needs like caching.
- 17:05It also needs message queues.
- 17:07It also needs like, whoa, I don't need all this stuff.
- 17:09I'll just, you know, you start to push people out, right, as you like overdo it.
- 17:12So, you know, how did you find that balance?
- 17:14I don't know that I have just yet.
- 17:16So I'll issue that disclaimer.
- 17:18But I will say that for my own uses, I do think that it meets a certain balance by being, I'm calling it radically decomposable.
- 17:30So what I mean by that is it is actually safe to strip away pretty much everything that comes sort of bundled by default with Flask Diamond and actually create a command line app that doesn't even use Flask to spin up a web server and a database model.
- 17:51I've actually used the whole Flask Diamond setup to create, yeah, really simple little scripts.
- 17:57But I've also used that basic pattern of a command line driver with a full-fledged SQLAlchemy database lurking behind it.
- 18:07And again, I'll use Flask Diamond to do that because it merely simplifies the interfaces and the process and the extensions and importing the database models and setting up the namespaces in a predictable way.
- 18:21You know, it does all of that for free such that I actually don't care if Flask happens to be a WSGI environment, you know, an HTTP server.
- 18:32I'm actually using it as just this really general purpose application framework.
- 18:37And I even consider the web part to be decomposable and extractable from the whole rest of the application platform.
- 18:47So what I'm saying is I don't even always write web apps with Flask anymore.
- 18:52There's a way of using the Flask application context to script an app that does not actually need to be running in conjunction with a WSGI server.
- 19:03It's an incredibly powerful pattern.
- 19:05And it's another thing that I would never do with a thing like Django.
- 19:10That is, it's very heavy.
- 19:12And when you start up a Django process, it's not that easy to slice out different pieces of the core.
- 19:20But with Flask, pretty much nothing is included in the core to begin with.
- 19:25Yeah, even Flask itself is made up of like a number of building blocks that are put together, like It's Dangerous and Vexig and those sorts of things, right?
- 19:33That's right.
- 19:34You know, you mentioned It's Dangerous.
- 19:36And one of the things that is kind of nice about folding in something like It's Dangerous using something like Flask Diamond is that by default, it's just folded in in a way that is going to work.
- 19:51So the pathway there is through Flask security and Flask security will sanitize all your inputs with It's Dangerous and perform all of the cross-site scripting protections.
- 20:04And so, you know, it's there.
- 20:06You know it's there and that your input will be sanitized.
- 20:10And frankly, if you don't want it, you don't have to have it.
- 20:14You can also get rid of all that.
- 20:20This portion of Talk Python To Me has been brought to you by Rollbar.
- 20:33One of the frustrating things about being a developer is dealing with errors.
- 20:37Relying on users to report errors, digging through log files, trying to debug issues, or a million alerts just flooding your inbox and ruining your day.
- 20:45With Rollbar's full stack error monitoring, you'll get the context, insights, and control of the data.
- 20:50All that you need to find and fix bugs faster.
- 20:52It's easy to install.
- 20:54You can start tracking production errors and deployments in eight minutes or even less.
- 20:58Rollbar works with all the major languages and frameworks, including the Python ones such as Django, Flask, Pyramid, as well as Ruby, JavaScript, Node, iOS, and Android.
- 21:08You can integrate Rollbar into your existing workflow.
- 21:10Send error alerts to Slack or HipChat.
- 21:12Or even automatically create issues in Jira, Pivotal Tracker, and a whole bunch more.
- 21:17Rollbar has put together a special offer for Talk Python To Me listeners.
- 21:20Visit rollbar.com slash Talk Python To Me.
- 21:23Sign up and get the bootstrap plan free for 90 days.
- 21:26That's 300,000 errors tracked all for free.
- 21:29But hey, just between you and me, I really hope you don't encounter that many errors.
- 21:32Loved by developers at awesome companies like Heroku, Twilio, Kayak, Instacart, Zendesk, Twitch, and more.
- 21:38Give Rollbar a try today.
- 21:40Go to rollbar.com slash Talk Python To Me.
- 21:51Before we get to the nitty-gritty details of it, tell me why and when did you create this?
- 21:56How old is this project?
- 21:57And what got you to say, all right, I'm making this thing?
- 22:00Totally.
- 22:00So this has been going on for years by this point.
- 22:04And it's the kind of thing that didn't happen intentionally.
- 22:08No one ever sits down and says, I'm going to write a framework today.
- 22:12But I needed it.
- 22:13I found that I just needed something to fill a missing spot in my research pipeline.
- 22:20Pipeline, basically.
- 22:22So I was doing a lot of work with online memes and their propagation through social networks.
- 22:31And so I was building a couple of web apps.
- 22:33And I guess this is 2011, 2012.
- 22:38I was using a framework called WebPy, which Reddit was using.
- 22:42And at the time, the principal author was a guy named Aaron Swartz, who died in early 2013.
- 22:50And the WebPy project died with him, as far as I can tell.
- 22:55So I needed something.
- 22:56Yeah.
- 22:57That whole story is super tragic.
- 22:58Yeah.
- 22:59It's unfortunate.
- 23:00Yeah.
- 23:00It's very sad.
- 23:01Yeah.
- 23:01It's interesting to consider some of just the rippling costs, the things that a huge tragedy,
- 23:09actually.
- 23:09And so when you're trying to do some kind of academic work that's going to be reproducible,
- 23:16be repeatable, the code needs to be shareable.
- 23:20It needs to be portable.
- 23:21You need to be able to give it to other people and they need to be able to run it.
- 23:26And it also needs to be able to run ideally 5, 10, 20 years in the future.
- 23:31And so a web framework that's not going to be evolving beyond 2012 or so is no good.
- 23:37So I experimented with Bottle and I liked it.
- 23:41And just I discovered Flask.
- 23:44It's kind of, I think, because of the plan words between Bottle and Flask.
- 23:49And in summer of 2013, I started really making some of these ideas into a repeatable template.
- 23:57So I was building, at this time, an application to model Twitter.
- 24:03I was scraping a ton of Twitter data.
- 24:05And so I had all these different types of objects.
- 24:09There were accounts and there were tweets and there were links between them and all the
- 24:13data model that you need to do to scrape Twitter.
- 24:17What I really needed was a way for other peers, collaborators to be able to look at this data
- 24:25without needing to understand SQL themselves, without needing to understand Python, ideally
- 24:31without even me needing to be there.
- 24:33And it was through Flask that I discovered this whole ecosystem then of things like Flask
- 24:39Flask admin and Flask security and the whole rest of it that I started assembling into this kind
- 24:46of research data support infrastructure.
- 24:51So all my data then I could put on a server somewhere in the cloud and just give a login to
- 24:58an advisor and they would be able to look at it.
- 25:01So the need was really, I just had so much data and I wanted to talk about it.
- 25:07I wanted to collaborate with it.
- 25:09And like I said earlier, I didn't want to have, I didn't want to be tied to the Django ORM.
- 25:15I just wanted to use SQLAlchemy.
- 25:17Cool.
- 25:17I think that's a really forward looking way of doing it.
- 25:20Here, I'm doing this research.
- 25:21I'm going to put it on the web.
- 25:22You can just execute it, slice it, dice it, whatever you want.
- 25:26This predates Docker, but it seems to me like Docker is being used by a lot of scientists
- 25:31for that purpose as well.
- 25:33Like I'm going to package up the execution of my analysis into a Docker image and then you
- 25:38can go do what you want.
- 25:40So it's like the next level or something.
- 25:42Yes, absolutely.
- 25:43A kind of anecdotal story is that back in the day, I was aware of a guy in this one department
- 25:50who needed, for timing purposes, he needed these 286s because that was the only thing that would
- 25:57execute his code at the right timing for a certain kind of reaction time task that he was recording.
- 26:03So he actually stockpiled these 286s.
- 26:07And I mean, by the way, this was happening in like 2008.
- 26:10So someone with a big pile of 286s, all for the purpose of getting the software to run exactly
- 26:16right decades after it was originally written.
- 26:19It's a serious problem.
- 26:20It really is.
- 26:21You take the 286, 16 megahertz and don't press the turbo button or it won't work right.
- 26:26Exactly.
- 26:27That'll screw up all your data.
- 26:29Yeah.
- 26:30But no, I mean, it's a real problem.
- 26:31And reproducibility is a big it's a hot topic in science right now, especially in the field
- 26:37of social psychology, which is kind of my home base right now.
- 26:41These issues of sharing data between labs and getting the same results, even when different
- 26:47researchers do it.
- 26:48It's actually getting a lot of cool papers written right now.
- 26:51So anyway, yeah, it's really important for data to be kind of social.
- 26:55Sure.
- 26:56I don't think that we as an industry or users or programmers across the board, we're not
- 27:03used to thinking of execution as a thing that has to be kept for long terms of period.
- 27:08We think about how are you going to archive data?
- 27:11How are you going to make that interoperable so you can read it in the future?
- 27:15But not like, how am I going to be able to run this algorithm that nobody's going to rewrite
- 27:20or something like this?
- 27:21This is an interesting problem.
- 27:23It's not something that affected my day to day life until relatively recently.
- 27:29But it gives me new respect for mainframe type stuff, like the whole IBM system 360 stack
- 27:38that goes back 50 years and what they have done to virtualize hardware and enable code, ancient
- 27:44code to still execute today.
- 27:46I mean, I think about just the horrors that the banks must be facing on a regular basis.
- 27:52So yeah, you know, let's be sensitive to those forward looking issues.
- 27:57And I don't know, maybe mitigate that a little bit.
- 28:00Fully the solution.
- 28:02But anyway.
- 28:02Yeah, it's a small deposit.
- 28:05But I think you're probably right that like emulation and virtualization and, you know,
- 28:10throw containers in there.
- 28:11Those will like alleviate that to some degree.
- 28:13But still, it's going to be tough.
- 28:14So there's a bunch of cool features to flash diamond.
- 28:17Let's let's dig into those for a bit.
- 28:18Yeah.
- 28:19So what I found was, you know, when we're talking about not wanting to repeat the same
- 28:25steps every single time you start a new application, I found there were a couple of features that
- 28:30pretty much every application I needed to build, it required those features.
- 28:36And I've already talked about some of these things that I just needed in the process of
- 28:40just normal, like I say, social data, like collaborative access to my data.
- 28:47And so this account management is a pretty obvious feature.
- 28:51It is provided by Flask admin in association with a number of other really helpful extensions.
- 28:58So I've already mentioned Flask security.
- 29:00And one of the things that I actually liked a lot about Django is the way that you get this
- 29:08GUI management interface kind of for free.
- 29:12Whatever your object model is, Django makes it so easy to get in there, see it in your web browser,
- 29:20create test data.
- 29:22And so that's something that Flask admin provides pretty easily.
- 29:26And so I really wanted to bake that in.
- 29:28So administrative access just works.
- 29:31And then databases are especially important for me.
- 29:35I've used a whole bunch of different SQL backends, but I've also used MongoDB very successfully
- 29:41with Flask.
- 29:42This is another instance where just because Flask diamond has a little opinion about databases
- 29:50and the basic entity relationship pattern for describing object models, despite that, it's
- 29:57really not very hard to switch that out for Mongo.
- 30:00And when I say not very hard, I mean five lines of code.
- 30:03There's no extremely deep epistemological commitment to using a SQL database just because the default
- 30:11is a SQL database.
- 30:12That's cool.
- 30:12And so you have a SQLAlchemy part of that story?
- 30:15In a couple of different ways, actually.
- 30:17So SQLAlchemy is not the only object relational mapper, but it has documentation that is spiritual.
- 30:27I think alchemy is a great term for what SQLAlchemy does.
- 30:32They go to crazy places in terms of what they are doing to layer the SQLAlchemy core on top of these
- 30:41relatively stupid databases.
- 30:44I'm just so impressed with what SQLAlchemy has done.
- 30:47Yeah, I really like it too.
- 30:48I use it a lot.
- 30:50Yeah.
- 30:50But, you know, there's other ones like PeeWee that are really popular and a lot of people like it.
- 30:56In terms of being opinionated, you know, in terms of offering these little opinions for optimizations,
- 31:02the reason that I'm going with SQLAlchemy is because sometimes there's just a really crazy thing that you just want to do.
- 31:12And they've already thought about it.
- 31:15I haven't found something that I can't do yet with SQLAlchemy.
- 31:18And if there is something that maybe you can't express with SQLAlchemy, you can always just drop to a database shell and do it directly in Postgres or whatever.
- 31:29So that's another thing that I never wanted to get too far away from was the ability to just physically interact with the database and not lose some connection back to the original web application.
- 31:42And like I say again, the alchemy is magic.
- 31:46Nice.
- 31:47What they have done makes it possible.
- 31:48Yeah, it is really great.
- 31:50I think it never ceases to amaze me that you really can keep on doing that.
- 31:54I can also model that and see what I mean, right?
- 31:56Yeah, basically, I think it's good enough for real research.
- 31:59Yeah, I totally agree.
- 32:00I guess that's the story.
- 32:01Yeah.
- 32:02Yeah, and there's a lot of interesting places using it in production.
- 32:05I forget some, I don't want to say the wrong one off the top of my head, but some really major apps that are very cool, major companies using it.
- 32:12You also talked about pointing Flask Diamond at existing databases and having presumably the SQLAlchemy classes, the models generated from existing databases.
- 32:25Tell us about that because that sounds like saving a ton of work.
- 32:28This is actually just some kind of experimentation that I've done on the side with some of my buddies.
- 32:32And we have done it successfully.
- 32:35SQLAlchemy ships with, it's a Python script that'll scrape your SQL schema and auto generate model code for you.
- 32:44So I don't want to give you the wrong idea that this is already baked into Flask Diamond.
- 32:49Simply that we have done it in a Flask Diamond app.
- 32:53It worked pretty much.
- 32:55And it did save us time in this one instance.
- 32:59So I mean, again, this is kind of like sort of spooky, pseudo-magical stuff here.
- 33:04And I'm saying like, yes, yes, this is possible, but I will only speak of it.
- 33:07I won't actually show you.
- 33:10But you'll just have to take my word for it.
- 33:13But it's possible.
- 33:13Yeah, I've done that before as well.
- 33:15I think there was a third-party package that didn't come directly from SQLAlchemy.
- 33:19That sounds right.
- 33:20Maybe the contrib.
- 33:22Yeah, it might have been contrib or something that was like, hey, this works with SQLAlchemy and it'll like read your schema and it'll actually generate your classes.
- 33:31And maybe the classes have stupid names and you need to go edit them a little bit.
- 33:34But still, like when you're looking at a big daunting database and you're like, oh, I got to get started with this.
- 33:40Like the ability to auto-generate or pre-generate like a starting place is really cool.
- 33:44Yeah.
- 33:45And it worked.
- 33:45Yeah, like I say, it worked most of the way.
- 33:47Which saves you most of the work.
- 33:49That's right.
- 33:50Yeah.
- 33:51That's awesome.
- 33:51You said it also has one of the features is model CRUD.
- 33:55Create, read, update, delete.
- 33:56Yeah, that's right.
- 33:57Create, read, update, delete is a really useful pattern that I've encountered all over the place.
- 34:02And all the more so with RESTful HTTP interfaces where the basic HTTP verbs more or less map on to create, read, update, and delete.
- 34:11And so I just found that I was doing this constantly.
- 34:15And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:16And so I wanted to do this.
- 34:17And so I wanted to do this.
- 34:18And so I wanted to persist that through just the general object model.
- 34:26And so this is actually implemented as a mix in that you can include with any SQLAlchemy object that you create.
- 34:35And it simply extends your model with create, read, update, and delete for free.
- 34:40And it extends it a little bit more with the ability to rapidly load and dump objects from JSON.
- 34:48Or you can extend it further for something like CSV.
- 34:51So the idea is to take some of the nice stuff from the GUI CRUD and enable that Pythonically.
- 34:59It's just a convenience thing, but I use it constantly.
- 35:04It's really the only way that I'm interacting with objects anymore is through this CRUD interface.
- 35:10Huge time saver for me, at least.
- 35:11Yeah, that sounds cool.
- 35:12Another thing a lot of apps need is email.
- 35:15Definitely.
- 35:16It's a necessary evil.
- 35:18Email is kind of an out-of-channel or an out-of-band way of communicating things like account changes.
- 35:28And actually, Flask security provides a number of features for email account confirmation if you're going to incorporate some kind of second factor authentication into your platform.
- 35:43So email is a necessary thing.
- 35:46It's provided by Flask mail.
- 35:48Again, needs to be integrated.
- 35:49And once again, Flask Diamond gives you an integrated email solution for free, batteries included.
- 35:56However, in this case, this is the kind of thing that not everybody needs.
- 36:01And so I've gone the extra step and I've actually commented out the one line that would enable email by default.
- 36:08And so if you find that you actually want it in your app, you are going to have to uncomment that line.
- 36:14But then, you know, emails is just there and it's free.
- 36:17And it works.
- 36:19Yeah, that's really great.
- 36:20And testing.
- 36:22One of the things I feel like is more possible, things like Flask, the micro frameworks, is because they're just less, they're easier to test.
- 36:30Yeah, it's possible to get in there and test some really low level things like the generation of signals or like I mentioned the application context earlier.
- 36:41The ability to create an application completely separate from any kind of web server or any kind of WSGI serving infrastructure is so powerful for testing.
- 36:52And so Flask testing makes some of these things really easy, like creating a debugging server and creating a phony HTTP test client for local testing of HTTP interfaces.
- 37:04So, of course, that's stitched in.
- 37:06But also, a simple testing framework is included with the scaffold to provide some examples of how you might use nose test, which is one of the Python testing suites.
- 37:21Other examples are pytest or Tox.
- 37:24And, you know, once again, you can actually use another testing platform, apart from nose, relatively easily.
- 37:31So I actually use Tox on a couple of projects.
- 37:34But the scaffold includes some, a pattern for building a test harness using nose tests and integrating it with the command line, making it pretty easy to run single tests, to run all of the tests, to automatically run tests when a file changes.
- 37:56Certain things that become really more like the DevOps side of things.
- 38:03Once again, a basic workable solution comes for free out of the box with Flask Diamond.
- 38:11And once again, it's the kind of thing that if you don't like it, you can just delete it and it's gone because it's really not baked in very deeply.
- 38:17It's just hooked in enough that it'll work, that the make file has a make test command and it'll do the right thing unless you don't want it to.
- 38:26Right.
- 38:27There's probably like a test stop py or something like that.
- 38:29Exactly.
- 38:30Hang around somewhere.
- 38:30Yeah.
- 38:31It was a test directory, but anyway.
- 38:33Right.
- 38:33Okay, sure.
- 38:34You could delete the test directory and you're done with the test if you don't want it or whatever.
- 38:37Yeah.
- 38:37This portion of Talk Python is brought to you by Hired.
- 38:52Hired is the platform for top Python developer jobs.
- 38:55Create your profile and instantly get access to 3,500 companies who will work to compete with you.
- 39:00Take it from one of Hired's users who recently got a job and said,
- 39:02I had my first offer on Thursday after going live on Monday and I ended up getting eight offers in total.
- 39:08I've worked with recruiters in the past, but they've always been pretty hit and miss.
- 39:11I tried LinkedIn, but I found Hired to be the best.
- 39:14I really like knowing the salary up front.
- 39:16Privacy was also a huge seller for me.
- 39:18Sounds awesome, doesn't it?
- 39:20Well, wait until you hear about the sign-in bonus.
- 39:22Everyone who accepts a job from Hired gets $1,000 sign-in bonus.
- 39:26And as Talk Python listeners, it gets way sweeter.
- 39:29Use the link Hired.com slash Talk Python To Me and Hired will double the signing bonus to $2,000.
- 39:33Opportunity's knocking.
- 39:35Visit Hired.com slash Talk Python To Me and answer the door.
- 39:46You also talked about deployment.
- 39:47How's the deployment different or enhanced with Plast Diamond?
- 39:51I came to really like a Python package called Fabric that abstracted away some of the weirdness of SSH and RSync and simplified some of the management of remote tasks that occur on your testing server or on your production server.
- 40:10And so I started baking this into the scaffold again.
- 40:14So what comes for free is a little fab file that actually I want to take a step back.
- 40:21For deployment, you can do it in a couple of different patterns.
- 40:24There's a way in which you could push your code to a central Git server or something like that and have all of your testing machines automatically pull from that server or have your production machines pull from that server.
- 40:37And so that's kind of a passive deployment.
- 40:40And then there's also an active deployment where you physically push the code to the machine that you're actually going to be running it on.
- 40:47You know, you don't relay it through some other intermediary server.
- 40:51And so I wanted to support both styles, actually, of deployment.
- 40:55And so that's supported with Fabric and with a command line interface, because this is the kind of thing that every command is a one off.
- 41:05And you just want to rapidly be able to SSH to a deployment server or push the code directly to a deployment server.
- 41:13And these things happen constantly.
- 41:15I just wanted, again, a simple solution that came for free out of the box.
- 41:20Yeah, that's cool.
- 41:20So nice that that's built in there.
- 41:23So another thing when I was cruising around your website that I saw, you were talking about facets.
- 41:28What are facets in this project?
- 41:30In a roundabout way, I've kind of been describing what these facets are.
- 41:35A facet is kind of a feature.
- 41:38So, you know, a facet is kind of like a face of a surface or as a play on words, a diamond is faceted with many faces.
- 41:47And so each of these features is actually a facet.
- 41:51So there's an account facet.
- 41:52There's an administration facet.
- 41:54There's a databases facet.
- 41:56There's an email facet and so on.
- 41:58And the basic idea is that together, these facets are the default types of considerations, the typical considerations that many of these web applications just require.
- 42:11You know, insofar as many of them need accounts and administration.
- 42:14Well, those are facets.
- 42:16At the Python level, each facet is really like a proxy for the extensions that are loaded to actually provide that facet.
- 42:27So I mentioned that Flask admin and Flask security have an interplay where admin uses security for login purposes.
- 42:39And the facets just ensure that those get that all the objects are created in the correct order and that Flask security knows about Flask admin.
- 42:49And what this means, again, Pythonically, is that you can either inherit and override or completely comment out any of these facets and really control whether or not your application has that facet at all.
- 43:05Right. Or replace it with something different.
- 43:07Exactly.
- 43:07Yeah. OK.
- 43:08And so it creates like a predictable hook where if you're going to use a different database, then that's where you do it.
- 43:16You know, you don't just randomly decide when you're sitting down to create the application that, you know, I'm going to do my database, whatever.
- 43:23This is predictable place where all the database stuff happens.
- 43:26You just go to the database facet.
- 43:29And if you're going to use Mongo, then you do it there.
- 43:32You just override, you inherit and override what I wrote.
- 43:36And boom, that's the right place or the opinionated place.
- 43:41Certainly not the right place, but that's the agreed upon place.
- 43:45Sure.
- 43:45I see.
- 43:47So it's kind of a convention.
- 43:48The facets sort of bundled, like your convention on top of like Flask security or some part of the API.
- 43:55Exactly.
- 43:55Convention is a good word for it.
- 43:57It's creating some conventions.
- 43:58OK.
- 43:59Conventions are good.
- 44:00That's cool.
- 44:01So let's assume that people out there are basically familiar with how you write Flask apps and how you write Django apps.
- 44:08Can you talk just a little bit about like, what does it look like?
- 44:11What's the API look like?
- 44:13Does it look a lot like Flask?
- 44:14Does it look like Django?
- 44:15Like what do I, what are the feelings I get when I write code in this, on top of this?
- 44:19Totally.
- 44:20I would expect it to be really familiar for Flask users.
- 44:25Because what comes out is actually a Flask application.
- 44:29The process starts off a lot like Django.
- 44:32You know, I was saying that Django has done such a great job of creating tutorials and making it easy for new users to get started.
- 44:41So just like Django, Flask Diamond begins with a scaffold and it creates a directory structure that would be really familiar to somebody who uses Django.
- 44:55So there's a manage.py and it does basically what you would expect.
- 44:58You can do manage.py server and then it'll, you know, just run your server or manage.py DB.
- 45:04And it gives you access to all of your database stuff.
- 45:08So in that sense, it's reminiscent of Django.
- 45:11And incidentally, all of that manage.py stuff is implemented with Flask script, another really great extension.
- 45:18But after you scaffold your application, it really comes to resemble Flask.
- 45:23The basic pattern uses the Flask create app idiom where somewhere in your project code, instead of just directly instantiating all of the Flask objects, you wrap that in a function called create app.
- 45:40And that really simplifies testing and it does all these things.
- 45:43And that's kind of the Flask way to do it.
- 45:45And all the extensions have an init app style of object creation.
- 45:51So Flask admin, it has a slightly opinionated way of setting it up.
- 45:57So once you have your application scaffold, it follows all the Flask conventions.
- 46:04You'll find a create app is inside your init file.
- 46:07And you'll find that each extension is created using the typical Flask init app idiom.
- 46:13I would expect that everything else should just look pretty much like another Flask scaffold.
- 46:19Okay.
- 46:20You might find online.
- 46:21Yeah, cool.
- 46:22So maybe not like a new Flask app, but like more, a more mature one you've dropped into or something.
- 46:26Yeah.
- 46:27Okay.
- 46:28You talked about the Django tutorials and documentation and they are really important.
- 46:33They make a big difference.
- 46:34Actually, when the Django tutorial switched from just by default recommending Python 3 over Python 2,
- 46:41that made a significantly measurable difference in Python 3 usage on PyPI.
- 46:47Yeah.
- 46:48So, you know, that I think speaks pretty strongly how powerful the Django documentation is.
- 46:53But yours is really nice as well.
- 46:55And you have a tutorial called Planet Tutorial, which I thought was cool.
- 46:59And it has a video as well as like a screencast video as well as just the steps, which I really like that.
- 47:06Yeah, thanks.
- 47:07Like I say, I'm really inspired by Django and what they have done.
- 47:11And one of the things that I've put a lot of time into over the years, because this is several years in the making,
- 47:20is creating some kind of a compelling story or a tutorial that kind of made sense at some level.
- 47:27And so I used to use an example about chess.
- 47:31And, you know, there's a board and there's pieces and there's players.
- 47:34And for some reason it didn't, I don't know, I guess I didn't care at a certain point.
- 47:40Like it wasn't interesting implementing chess.
- 47:42And I had a breakthrough a couple of months ago when I realized that whatever tutorial I write about,
- 47:50it really needs to ship with working code.
- 47:54The two need to play off of each other.
- 47:57So over the course of a couple of weeks, these ideas kind of came together.
- 48:00And the planets tutorial actually ships as another code scaffold.
- 48:04There's only two that ship with Flask Diamond.
- 48:07The one will create an application for you.
- 48:10And the other will set up this planets tutorial.
- 48:12And so it's working code that comes in the package and it maps on to the documentation.
- 48:18So the idea is it should be a consistent story.
- 48:21Part of why that's important is to make it possible.
- 48:26So let's assume that you're doing some team collaboration, some development that involves a couple of people.
- 48:32And let's assume that they know Python and maybe even they know Flask already.
- 48:37The idea is you should be able to point them at something and make it pretty easy for people to become initiated or get up to speed such that they can collaborate.
- 48:47So the planets tutorial is really just there's planets and there's moons or there's satellites.
- 48:53And it walks through creating Earth and Mars and Venus and just adding a couple of moons around those planets.
- 49:01And at that level, it's actually pretty pedestrian.
- 49:04There's some simple models.
- 49:06But I just kind of liked the story a little bit more than, I don't know.
- 49:10It sounds intriguing.
- 49:12Like I want to go through a planets tutorial.
- 49:14Yeah.
- 49:15Well, hey, it's an 11 minute video.
- 49:17So nice.
- 49:20How about how are you using this?
- 49:22You said you're using this in a few interesting ways in production today, right?
- 49:25Yeah.
- 49:25So I am actually using it in production.
- 49:27And I gave a few examples of some research projects where I wanted advisors or peers to have access to this stuff.
- 49:38But I've done a couple of other projects more recently that are actually live and out there and even potentially getting some decent traffic.
- 49:47So peopleapi.com.
- 49:50So that's P-P-L-A-P-I dot com is something I've been working on for a couple of years.
- 49:55It's part of my dissertation work.
- 49:58It's a virtual database of the human population.
- 50:01So for everyone who is alive, approximately in 2014, that was about 7.2 billion people.
- 50:07There's an entry in this database for everybody.
- 50:11Now, to be clear, it's synthetic data that's not actually scraped from Facebook or something like that.
- 50:18I have a bunch of algorithms based on demographics that make guesses about where everybody is and how old they are and all that stuff.
- 50:27And, you know, and the guesses are pretty good.
- 50:30But the idea is that they're not real people just yet.
- 50:33But it's billions.
- 50:34I mean, it's a really big database.
- 50:36That is a big database.
- 50:37Yeah, something like seven terabytes.
- 50:40And I was really happy that this got featured on Hacker News and Product Hunt last week.
- 50:46And the website did not fall over.
- 50:50I was sustaining 150 simultaneous connections.
- 50:54And it held up on a virtual machine in the Digital Ocean cloud.
- 51:01So that was actually a pretty cool validation of the ability of one of these applications to sustain moderate traffic.
- 51:11And it's also a demonstration of the ability to manage a pretty sizable database using SQLAlchemy and exposing that over the web and coping with some kind of scale, coping with, like I say, a little, like a moderate amount of traffic.
- 51:26So I'm pretty happy about that.
- 51:28PPL API dot com.
- 51:29But another thing that I'm doing that kind of relates to me as an open source developer is that I've been looking at GitHub.
- 51:38And they have a ton of data available through their API.
- 51:42And there are actually a bunch of academics out there who are scraping GitHub.
- 51:47There's a lot of interesting research you can do with that data.
- 51:51So I have created an analysis called GH Impact.
- 51:55This relates to the number of projects that have a certain number of stars or more.
- 52:01So if you have 10 projects with at least 10 stars, then you have a GH Impact score of 10.
- 52:07And if you have 100 projects, each with 100 stars or more, then you have a score of 100.
- 52:13And only companies like Google and Microsoft and Mozilla are able to get these scores that are really high, to have 100 projects.
- 52:23And every single one of those projects is well liked on GitHub.
- 52:26And typically, even prolific developers have fewer projects and they get fewer stars.
- 52:33Or if they have one popular project, then they probably don't have a second popular project.
- 52:39So this is kind of a social analysis of the impact that people are able to achieve through a platform like GitHub.
- 52:48Once again, this is live on the Internet.
- 52:51And once again, I did all the data modeling with Flask Diamond.
- 52:55And in this case, one of the ways that that was really useful was the ability to extract small amounts of data from this, you know, this like 150 gigabyte database through a REST API.
- 53:09And so that enabled me to use a statistical package called R to not have to load the whole 150 gigabyte database.
- 53:18I was able to use a little tiny bit of data through the REST interface that I built.
- 53:24In that manner, I was able to fit my analysis in RAM.
- 53:28Because R is just not powerful enough to deal with an enormous database of many gigabytes.
- 53:34And so for certain analyses, a tool like Flask Diamond fills a really crucial data translation role of adapting huge data down to relatively underpowered statistical workstations.
- 53:50Yeah, that's cool.
- 53:51So is it kind of like, did you kind of like sample or poll the GitHub population and then compare name you put in there against that?
- 53:59No, I got all of it with like certain caveats.
- 54:01I scraped as much as these other researchers over in the Netherlands have scraped.
- 54:07Their project is called GH Torrent.
- 54:09The torrent thing is, I think, irrelevant.
- 54:12Now I'm pretty sure it's just a distributed scraping project.
- 54:15As much as they were able to scrape, which is, I think, you know, certainly more than 90% of GitHub.
- 54:20Yeah, that should be statistically relevant.
- 54:22Yeah.
- 54:23Yeah, yeah.
- 54:24I got all of it.
- 54:24So, no, I didn't sample any of it.
- 54:26I just extracted specific columns and subsetted the data so that I was able to fit only what I cared about into RAM and ignore the rest.
- 54:36Nice.
- 54:37So I had to type my name into it because it's the only one I knew off the top of my head.
- 54:40I have a GitHub impact score of eight and a 99 percentile.
- 54:43Yeah, yeah.
- 54:44That's cool.
- 54:45It ceilings out pretty rapidly.
- 54:47And, you know, so, you know, your score might be a little bit higher than that because, like I say, maybe they haven't scraped the whole thing just yet.
- 54:55But, yeah, what that means is you have at least eight projects with each eight stars or more.
- 55:00In all likelihood, some of those projects have way more than eight stars.
- 55:04But the way that it draws the line is I guess they're not nine projects each with at least nine stars.
- 55:10Yeah, that sounds right to me, actually.
- 55:12It's pretty cool.
- 55:12It's a cool measurement.
- 55:13Yeah, thanks.
- 55:15Yeah.
- 55:15They like it in academia.
- 55:16So, anyway.
- 55:17Yeah, very nice.
- 55:18So, the last one that you want to talk about in production is GThink.
- 55:22This one's a weird one.
- 55:23Without the I.
- 55:24G-T-H-N-K dot com.
- 55:27Yeah.
- 55:27So, I do pronounce it GThink.
- 55:29So, you got that right.
- 55:30It's not actually hosted remotely.
- 55:33This is one that you download and then you run it locally.
- 55:37And on OS X, GThink installs as a launch service.
- 55:42So, it's just kind of always running in the background.
- 55:45And it's a note-taking application of sorts.
- 55:50It's not in the cloud.
- 55:51You know, it's not hosted remotely, which is, I believe, a security feature.
- 55:56Like, I really don't trust a hosted cloud service to store my personal notes.
- 56:03I would much rather just have a program running on my own computer.
- 56:07That's what GThink is.
- 56:08It's like a self-hosted Evernote or something along those lines.
- 56:12Okay, cool.
- 56:13It demonstrates that Flash Diamond can be packaged in a couple of different ways.
- 56:17Not only hosted online.
- 56:18That is really cool to have it as a desktop app.
- 56:20Okay, nice.
- 56:21That's quite an interesting twist.
- 56:23So, tell me the story of Python 2 versus Python 3 with your project.
- 56:28Yeah.
- 56:28This was a bit of a struggle, actually.
- 56:31Because the ecosystem was a real barrier.
- 56:36Insofar as all the packages that Flash Diamond relies upon, they all need to have made the switch to Python 3.
- 56:44And by now they have.
- 56:45But also, you know, there was a little bit of stuff inside Flash Diamond itself that needed to be updated.
- 56:51I eventually made the leap within the last year.
- 56:54But I think I found that Travis, actually, in automated testing, is a real asset with Python 2 and Python 3 compatibility.
- 57:04So, the ability to automatically run the test suite with different Python interpreters has saved me a lot of headaches.
- 57:11Because I'm catching a lot of bugs that, well, less now the transition has been made.
- 57:16But it caught an awful lot of bugs moving from 2 to 3.
- 57:19But I find now that I make all my new projects using Python 3.
- 57:25And personally, I'm really enjoying what's happened with Python 3.
- 57:30And I do kind of, I check in on the arguments whenever it comes up.
- 57:36You know, why isn't Python 3 whatever?
- 57:38I like to sort of torture myself reading that stuff online.
- 57:42Because I was held back for quite a while on Python 2.7.
- 57:46Now that I have made the switch, there's no going back.
- 57:49Yeah.
- 57:50I really do like that.
- 57:51Yeah, I'm with you.
- 57:51There's a whole bunch of cool stuff.
- 57:53Especially around concurrency and async stuff.
- 57:55And just a lot of polish on the language.
- 57:57Yeah.
- 57:58Strings and bytes and Unicode.
- 58:00It's so much better.
- 58:01I feel like we, as a community, have sort of turned the corner.
- 58:05A year ago, a few years, it wasn't entirely clear that Python 3 was like,
- 58:11of course you should be doing it.
- 58:12People were still like, no, I don't know about this.
- 58:14I feel like most people, even though maybe they have a project that's not quite converted
- 58:19or they don't foresee themselves able to move whatever project to Python 3,
- 58:24like the recognition that it is the way to go, I think is definitely growing.
- 58:29So I think it's a pretty positive move.
- 58:30Yeah.
- 58:31I think finally the critical mass is there.
- 58:33Yeah.
- 58:33And it's the way forward, clearly.
- 58:36Absolutely.
- 58:37Absolutely.
- 58:37All right.
- 58:38Well, your project looks really cool.
- 58:39I feel like, you know, we've got Flask at one end with the micro frameworks.
- 58:44We've got Django at the other end.
- 58:45It's more sort of full-featured building blocks.
- 58:48I talked with Julia Ellman and Mark Levin on episode 88 about a lightweight Django and bringing,
- 58:56you know, sort of unrolling some of the stuff out of Django to make more lightweight,
- 59:00to bend it however you want.
- 59:02And this is kind of taking some of the niceties of Django, put it in a flask, and you're kind
- 59:06of like filling out the spectrum.
- 59:07I hope so.
- 59:08Yeah.
- 59:09So it sounds, I think it's a cool contribution.
- 59:11Yeah.
- 59:11Thanks.
- 59:12Yeah.
- 59:12So let's see, before we go, let me ask you the two final questions.
- 59:15If you're going to write some Python code, what editor do you use?
- 59:18It's Sublime Text 3 these days.
- 59:20It's Python all the way down.
- 59:22I love Emacs.
- 59:25I love the Emacs philosophy.
- 59:26And I love Lisp.
- 59:28But the idea of redoing Emacs with Python as its heart and its brain is too cool.
- 59:37So it's Sublime Text.
- 59:39Yeah.
- 59:39That's pretty cool.
- 59:40Have you seen the Anaconda plugin for it?
- 59:45I have not.
- 59:46It's not the same as the Anaconda distribution.
- 59:48I think these things are unrelated.
- 59:49But it's like an extension for Sublime that brings all sorts of Python features, apparently.
- 59:54I just ran across it recently.
- 59:56But I haven't really explored it.
- 59:57Yeah.
- 59:58I would have just discounted it as just packaging of the other Anaconda.
- 1:00:02Well, that's awesome, actually.
- 1:00:03I'm going to check it out.
- 1:00:04Yeah.
- 1:00:05I'm quite sure that it's a different sort of thing.
- 1:00:09Cool.
- 1:00:09Yeah.
- 1:00:09Cool.
- 1:00:09So I'll put a link.
- 1:00:11Yeah.
- 1:00:11So here it says, I open it up and it says, Anaconda, the Sublime Text 3 Python IDE.
- 1:00:18And it gives you all sorts of functionality.
- 1:00:20Yeah.
- 1:00:20So it's not the same thing as the Anaconda.
- 1:00:23It's a different thing.
- 1:00:24Check it out.
- 1:00:25I'm giving that a look.
- 1:00:26Yeah.
- 1:00:26Awesome.
- 1:00:27Okay.
- 1:00:27And then there's over 96,000 PyPI packages.
- 1:00:31I can't wait till it gets to 100,000.
- 1:00:32There's got to be some kind of celebration.
- 1:00:34But why don't you tell people about some that you think are cool they should know about.
- 1:00:40Check out.
- 1:00:40All right.
- 1:00:41So I've already said so many good things about Flask and Sequel Alchemy.
- 1:00:46Together, they have changed my life, I think, probably for the better.
- 1:00:51So everybody needs to go look at those two.
- 1:00:54But I also just want to, there's a special place in my heart for Beautiful Soup.
- 1:00:59It's a throwback to an earlier time.
- 1:01:02But when Beautiful Soup came along and made it easy for me to parse even really broken and terrible HTML,
- 1:01:11and actually I was able to start doing useful stuff with web scraping,
- 1:01:16and I began sort of collecting some data that I was unable to access before.
- 1:01:22I think there's a way that Beautiful Soup might have improved my life more than anything else in PyPI.
- 1:01:29That's really cool.
- 1:01:31It's a special place in my heart for that one.
- 1:01:33Yeah.
- 1:01:34You talked about the alchemy.
- 1:01:35The alchemy nature of Sequel Alchemy.
- 1:01:37Beautiful Soup is kind of magical as well.
- 1:01:39Yeah.
- 1:01:40Everything becomes an API even if it's not supposed to be.
- 1:01:44Right.
- 1:01:45Awesome.
- 1:01:47And it's surprisingly easy to use.
- 1:01:48So if you guys need to do web scraping, check it out.
- 1:01:50It's definitely cool.
- 1:01:51I can recommend it as well.
- 1:01:52All right.
- 1:01:53How about a final call to action?
- 1:01:55You looking for contributors to this project, people to try it out?
- 1:01:58Yeah.
- 1:01:59Definitely check out the website flask-diamond.org.
- 1:02:04That'll link you through to GitHub.
- 1:02:06I'm looking for people to battle test this on Windows because that's harder for me to do.
- 1:02:12And ideally give me feedback.
- 1:02:15Or even better would actually be some edits to the documentation because I want to break down the barriers to get some new users initiated into this flask ecosystem.
- 1:02:26Yeah.
- 1:02:26That sounds great.
- 1:02:27You know, people are always asking me like how they can contribute to open source.
- 1:02:30Like something that just came to mind is maybe they could come write a tutorial and you could have like a whole bunch of tutorials.
- 1:02:35Right.
- 1:02:36That'd be a fun way to like a fun and easy way to get started.
- 1:02:38Right.
- 1:02:38I would love that.
- 1:02:39And, you know, make a screencast video.
- 1:02:41And man, you're you're you'll be my friend for life.
- 1:02:46That's awesome.
- 1:02:46All right.
- 1:02:47Well, this is a really cool project.
- 1:02:48And I think it's, you know, fills an interesting space in the spectrum of the web and Python.
- 1:02:53So thanks for building it.
- 1:02:54And thanks for taking the time to share the story.
- 1:02:56Thanks.
- 1:02:56It was really my pleasure.
- 1:02:57You bet.
- 1:02:58Bye.
- 1:02:59This episode's guest has been Ian Dennis Miller.
- 1:03:02And the episode has been sponsored by Rollbar and Hired.
- 1:03:06Thank you both for supporting the show.
- 1:03:08Rollbar takes the pain out of errors.
- 1:03:11They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.
- 1:03:19As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash Talk Python To Me.
- 1:03:26Hired wants to help you find your next big thing.
- 1:03:29Visit Hired.com slash Talk Python To Me to get five or more offers with salary and equity presented right up front and a special listener signing bonus of $2,000.
- 1:03:37Are you or a colleague trying to learn Python?
- 1:03:40Have you tried books and videos that just left you bored by covering topics point by point?
- 1:03:45Well, check out my online course, Python Jumpstart by Building 10 Apps at talkpython.fm/course to experience a more engaging way to learn Python.
- 1:03:54And if you're looking for something a little more advanced, try my WritePythonic code course at talkpython.fm/Pythonic.
- 1:04:01Be sure to subscribe to the show.
- 1:04:03Open your favorite podcatcher and search for Python.
- 1:04:05We should be right at the top.
- 1:04:07You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 1:04:16Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
- 1:04:21Corey just recently started selling his tracks on iTunes, so I recommend you check it out at talkpython.fm/music.
- 1:04:28You can browse his tracks he has for sale on iTunes and listen to the full-length version of the theme song.
- 1:04:34This is your host, Michael Kennedy.
- 1:04:35Thanks so much for listening.
- 1:04:36I really appreciate it.
- 1:04:38Smix, let's get out of here.
- 1:04:40Smix, let's get out of here.
- 1:04:40Outro Music.
- 1:05:01Bye.
- 1:05:02.