Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 70, recorded March 15, 2018.
I'm Michael Kennedy.
And I'm Brian Okken.
Brian, how are you doing?
I'm doing great. It's good to talk to you again.
Yeah, you as well. Super excited to talk about some of these things that you got here.
Before we do, though, let's just say real quick thanks to DigitalOcean.
They're sponsoring this episode like they do many of the episodes, so check them out at do.co.python.
You know, I'm a big fan of Cookie Cutter. I've done a couple of things with it.
Yeah, actually, I'm warming up to it, and I use it for quite a bit now.
That's nice. You've found an interesting online Cookie Cutter thing. What is this?
It's from Konstantin Pavlovsky. That's a cool name.
Anyway, online Cookie Cutter generator.
And so Cookie Cutter is a command line thing where you point it at, you give it a link to usually a GitHub Cookie Cutter,
but you can have them be local also. And it starts asking you questions about what you want to fill in the project,
and then it starts like a Python project for you. You could probably describe it better.
It's more of a templating thing you could do anything with.
It's pretty interesting. So the way Cookie Cutter works is it's a CLI thing, and you run it,
and it will ask you questions, right? Like, what's your email address? What's your full name?
What do you want to call the project? Do you want to use Jinja 2 or Chameleon Template, etc., etc.?
This is like that, but it's like a website with a web form that asks the questions like that way, right?
Right. So he doesn't have, like, everything up, but he's got quite a few up now that are some of the common templates,
the PyPackage and PyPackage Minimal and a Flask and Bottle and actually quite a few others.
And instead of doing it on a command line, you select it, and it shows you basically all of the questions that you're going to get asked.
And you can just fill it in and then generate project, and it generates a zip file for you, and you can download it.
So basically, like, if you don't have Cookie Cutter installed, you can still execute the Cookie Cutter template by going to the site.
Yeah.
Nice.
If you just kind of want to see all of the questions before you get going, gather those up first.
That's quite cool.
I thought it was neat, and he's a pretty cool guy on Twitter, so if you have a favorite Cookie Cutter that you'd like to have him put up there,
I bet if you just contacted him, he'd probably put it up there.
Yeah, for sure. Very cool. So check out the online Cookie Cutter generator. I like it.
So did we go on, like, a rant about GUIs for a while?
Yeah, for a bit, yeah.
So I'm not exactly going to talk about, like, another GUI platform that, like, I don't know, takes restructured text and turns into a UI.
Nothing like that.
But there is a really cool project that integrates with standard Python logging.
So Python logging works in a certain way where it's got, like, the time and then, like, the module or the category and then the level, like, trace or info or error, and then the message, things like that.
So someone built a really cool UI that will let you, in real time, watch and accumulate the logs into a rich application just by starting up and running it.
Oh, yeah, this is actually really cool.
Plus, you can filter your different levels and filter them out.
Exactly.
So, like, imagine, like, if you want to tail your log, right?
I'm going to tail it and see what's coming through.
And then it's just, like, ripping by.
You're like, oh, my gosh, there's all this stuff.
Was there an error?
I'm going to search.
Oh, like, it's kind of hard to correlate, right?
So what you do is you install into your app, you install a socket handler as one of the trace sources.
And then you just, this just listens to that UDP source.
So you install, like, a socket handler thing.
And then you run this app and it just, boom, it just starts capturing the logs in real time as if you're tailing them.
But with a UI, you can filter and sort and interact with.
Yeah, and change the color on them and stuff.
It's got a dark mode.
You know it's for developers.
Yeah.
Yeah, but quick shout out to just the framework, though.
It is based on PyQT5.
And it's all open source.
So you can go check it out and see how they built it.
It's a pretty decent looking app.
Yeah.
And actually, I haven't been putting a lot of levels of logging in some of the work apps that I do.
But I might with having this logger like that.
It's pretty cool.
So it allows any number of simultaneous connections.
So you can have different people can watch it.
You can change the look of the feel.
You can filter, like you said.
You can search.
You can view exceptions and tracebacks and stuff on separate windows.
So you can pop out the traceback and just look at the details.
It's pretty cool.
Yeah.
Okay.
Yeah, very nice.
So there's a really cool CMS for Python called Wagtail, right?
Yeah.
And I'm actually surprised we haven't talked about it yet.
But there's, I know that when I think of a CMS, I'm usually thinking like for a lot of stuff, I think of like maybe WordPress or what's that other popular one?
Like Squarespace, something like that.
Drupal, Drupal.
Drupal, that's it.
Yeah, there is one for, there's actually, I think there's several for Python, but Wagtail is one of the more popular ones.
And it's got a really nice look.
And 2.0 just came out.
And they're pretty excited about it.
We did cover Django 2.0 changes recently.
And this Wagtail 2 does support Django 2.0.
And there's apparently a better, newer text editor that they're excited about.
And some fixes in scheduling your published content.
Yeah, it's awesome that it's based on Django 2.0.
And of course, that means goodbye Legacy Python as well, right?
Yeah.
But one of the things that I wanted to highlight as well while we're talking about Wagtail is if I'm thinking about a different framework,
often I kind of want to know really what it's going to be like.
And that's really hard to tell without just starting it.
But they do have a couple things to help.
There's a, we're going to link to both of these.
One of them is a gallery of sites made with Wagtail.
So it isn't really how to do this, but these are things that are possible with this framework.
And some of them are professional and they look really nice.
Yeah, they do look really nice.
And like the whole, what one is it?
It's the Royal College of Art in London.
Its entire site is driven by Wagtail.
Wow, that's nice.
And then there's a couple of e-commerce sites that are in there too.
So you can set up e-commerce as well.
And then the other thing is they have a Zen of Wagtail page that talks about,
they have kind of their design philosophy of how they're set up their code and what they're in with the end user.
So it's neat.
I like it that they have that kind of philosophical guidance to help you to go along.
It's cool.
Yeah, I would definitely consider Wagtail if I was building a site and other people had to add stuff to it who were not developers.
And you wanted it to be CMS-like.
It's very cool.
Yeah, actually, I think I'm going to set up something for work using Wagtail just to try it out.
Yeah, super nice.
So speaking of setting up stuff, let me tell you about DigitalOcean.
So with DigitalOcean, you know that you go and create a new server and you get like a Linux machine and some variety that you pick.
You SSH in and then you begin your process of building your infrastructure, right?
Do you want WordPress?
Then you've got to go set that up.
You want Django.
You've got to like make sure Python's installed and all the things are all set up and whatnot.
That doesn't even mention the database, right?
So one of the cool things that they have that I want to highlight is they have the ability to create what they call one-click apps.
And those are actually entire virtual machines that are pre-configured to run the thing that you want.
So you want a ghost for, you know, like that blog service, static blog service, whatever it is.
So you just click, go to the one-click apps and say, I want a ghost server.
Boom, it's up and running.
You want a MySQL server?
Click that.
You got it.
MongoDB configured so it's all safe on the network.
Click that.
Super cool.
They have Discourse.
They have WordPress.
They even have a machine learning and AI pre-built thing.
So you want to click that and then just log in and start doing your TensorFlow and things like that.
It's just like ready to roll.
Yeah.
One of the things I like, they have a GitLab one so you can set up your own, like your own team GitHub-like thing.
Yeah, that's super cool.
And you don't need to know that much about it, right?
It's like all the stuff is set up and running.
You just have to be able to keep it running more or less.
Cool.
Nice.
All right, yeah.
So check them out at do.co slash Python.
And they're big supporters of the show.
So check out their stuff.
Tell them thanks.
So I'm a big fan of databases.
We talked about MySQL and MongoDB there.
What's the most popular way of accessing databases, you think?
What would you use?
Raw SQL statements.
I'm sure it's the most popular.
But outside of that, I'm thinking like Django ORM, SQLAlchemy.
Like these are the major tools, right?
Yeah, ORMS.
Yeah, the ORMS.
So there's another one that's really cool that's really small and lightweight called PeeWee.
You would never know by the name.
It's a good name, actually.
I like it.
It is a good name.
So it's a simple and small ORM.
There's a few but very expressive concepts to make it easy to learn, intuitive to use, and so on, right?
That's what they say about it.
It's been around for a while.
But the news is they did a complete rewrite of it and released PeeWee 3.0.
Nice.
Yeah, so it's pretty cool.
It's developed with Python 3.6, so it embraces all those features.
It has built-in support for SQLite, MySQL, and Postgres.
Those are all nice.
And it has extensions for things like full-text search and migrations and whatnot.
So that doesn't sound so PeeWee.
Actually, that's a lot of features.
It's a lot of cool stuff.
One of the reasons it's really interesting to me is because there's a separate project called PeeWee Async.
Okay.
One of the challenges you have, like, doing any async stuff is, like, everything that is blocking or slow has to be async, or there's kind of no point to even getting started, right?
If I'm going to call a web service, I have to use, like, the async, the AIo HTTP client, or it just doesn't make sense, right?
It's just blocking.
Like, there's no async behaviors.
And you run into that problem often with accessing databases, like, say, SQLAlchemy and stuff.
So this thing, PeeWee Async, will let you add async ability to your queries.
So it's super cool.
So you're going to go, if you want to insert something, you would just say, like, await objects.create, and you pass off the object you're going to insert to the database.
You want to do a query, you just say, like, all objects equals await objects.execute, like, you know, your model.select, like, in the syntax.
So it basically allows you to just plug in this async and await to very, very minimal effort to make your code much more scalable.
That's pretty cool.
Yeah.
Neat.
Yeah.
So I'm pretty excited to see them doing this.
This is really cool.
I don't know a whole lot more.
I think this is a really cool thing that's out there, and I wanted to shine a little bit of a light on it because I think Django and SQLAlchemy get most of the sunshine.
Yeah.
So I told you that DigitalOcean, you can go push that button and create a machine learning thing.
But what if you don't know about machine learning?
Which I'm kind of in that camp.
I know most of the buzzwords, but I haven't really done much work in it.
So I was excited to see that there was somebody that put up a repo, a GitHub repo, called Machine Learning Basics.
And the idea behind this is it's a repository of a lot of the machine describing and showing a lot of the machine learning algorithms,
but not necessarily how you would do it in production because in production you've got all these fancy server tools that you can use to make things really fast.
But if you're just trying to understand the concepts, I want to see the code.
And so what they've set up is a bunch of Jupyter Notebooks, actually, to go through and describe how you would do it in raw Python.
How would you do, what does it mean to do linear regression or logistic regression or K means clustering or K nearest neighbor?
And there's a bunch of different algorithms there.
And if you're just sort of learning what these are, being able to look right at the code and being able to play with it,
I think that that might help before you jump into using some of these extra tools.
I think this is really cool.
And it's super simple.
The pictures and graphics are really clear.
The notebooks are just a couple of pages.
And yeah, it's just pure Python, right?
It's not like, oh, you call this thing a TensorFlow, then magic, magic things happen, right?
It really shows you the steps.
So quite nice.
Right.
I mean, when I'm just learning stuff, I don't need it to be fast.
I just, and I don't need to hook up to TensorFlow right away.
I don't even, I just want to know more about this stuff.
This is a great thing.
Yeah, definitely.
Yeah, well done.
And if you're getting started in that, definitely check that link out.
All right.
So final thing I want to talk about is Severus.
Very cool name for a project.
It is a cool name.
So it's got this, I think, Greek name.
I'm not sure.
So it's the name for the god or the character that is the watchdog of Hades, whose duty it was to guard the entrance.
So the idea is that this is a validation framework created by Nicola Ioroshi.
And what you do is you can give it like a schema.
So the schema is a dictionary.
It has the names of the fields.
And then you can do type validation, min max validation, all sorts of different things that you can plug in there.
So you create this dictionary that's where it says, these are the fields I want to validate.
And here's their types and restrictions and whatnot.
And then if you receive any form of document, it could be from like a rest post.
It could be something you'd read out or write to a database, whatever, any kind of dictionary.
You can just say validate this.
And it'll go through and validate.
So like make sure that, say, the name is a string or if you say the age is five, but in your schema you said it's an integer and the minimum is 10, you'll get an error back.
Sorry, there's a problem or a set of problems.
One of them is the age and the min value is 10, but you get five.
Okay.
What do you pass it?
Is it JSON or?
No, it's just a dictionary.
Okay.
Yeah.
So it looks very JSON-y, but you just give it any dictionary.
And so anytime you're reading data that comes in in a dictionary form and you want to validate it, this is a really rich and extensible way to do that, right?
So quite cool.
That's a great way to write at your API level to make sure that bad data doesn't go down to the rest.
Then you can simplify your code in the rest of your project because you can assume that data is going to be in the right forms.
Absolutely.
Like these fields are required.
It has to be this format.
You don't have to go, okay, well, I know it comes in the string.
Can I convert it to an integer?
No, that's an exception.
Okay.
So then I'm going to capture that error and say it back, right?
There's just so many like if statements and like clauses for testing.
And you could just define these schemas in one place, call validate when you get the data and off you go.
It's really, really nice.
Nice and really very cool that you put that as a separate project so that other projects can use it.
Exactly.
So this is used in the E framework, which is a restful framework based on Flask and Mongo.
But instead of baking that into the framework, it's like I'm going to create this validation thing, which is totally separate.
It makes sense to be used wherever, but it just also happens to be the validation layer in the rest framework.
So quite cool.
Neat.
Yeah.
Very, very neat.
All right.
For all the cool things you found.
Yeah.
Thank you.
Bye.
Hey everyone.
Just a quick bit of news before we get out of here.
When Brian and I recorded, I didn't have anything to share, so we didn't talk about it.
Since then, I've just launched a new course over at Talk Python Training, and it's called 100 Days of Code with Python.
So if you're thinking about doing 100 days of code or you want this big challenge where you write a little bit of code each day,
check out the course at talkpython.fm/100 days.
So 100 days.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at Python Bytes.fm.
If you have a news item you want featured, just visit Python Bytes.fm and send it our way.
We're always on the lookout for sharing something cool.
On behalf of myself and Brian Okken, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.