Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

Transcript #70: Have you seen my log? It's cute!

Return to episode page view on github
Recorded on Thursday, Mar 15, 2018.

00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 70 recorded March 15th 2018 I'm Michael Kennedy and I'm Brian Okken Brian. How you doing? I'm doing great. It's good to talk to you again Yeah, you as well. It's 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 digital ocean They're sponsoring this episode like they do many of the episodes so check them out at do dot CEO slash 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. No, that's nice. You found an Interesting online cookie cutter thing. What is this? It's from Konstantin Pavlovsky that's cool name anyway online cookie cutter generator and so cookie cutter is a command-line thing where you pointed at a you give it a Link to a usually a github cookie cutter, but you can have them leave 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.

01:05 You could probably describe it better. It's more of a templating thing you could do anything with.

01:08 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.

01:14 Right, like what's your email address? What's your full name? What do you want to call the project?

01:18 Do you want to use Ginger 2 or Chameleon Templates, etc, etc.

01:21 This is like that but it's like a website with a web form that ask the questions like that way right?

01:28 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 like the PyPackage and PyPackage minimal and a flask and bottle and a few and actually quite a few others.

01:44 And instead of doing a command line, you select it and it shows you basically all the questions that you're gonna get asked.

01:52 And you can just fill it in and then generate project and it generates a zip file for you and you can download it.

01:58 So basically, like if you don't have cookie cutter installed, you can still execute the cookie cutter template by going to the site.

02:05 Yeah, you just kind of want to see all of the all the questions before you get going, gather those up first.

02:11 That's quite cool.

02:12 I thought it was neat and he's a pretty cool guy on Twitter.

02:15 So if you have a favorite cookie cutter that you'd like to have him put up there, I bet you if you just contacted him, he'd probably put it up there.

02:23 Yeah, for sure.

02:24 Very cool.

02:25 So check out the online cookie cutter generator.

02:27 I like it.

02:28 So did we go on like a rant about GUIs for a while?

02:32 Yeah, for a bit.

02:33 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.

02:41 But there is a really cool project that integrates with standard Python logging.

02:46 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.

02:58 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.

03:10 this is actually really cool.

03:12 Plus you can filter your different levels and filter them out.

03:14 - Exactly, so like imagine, like if you wanna tail your log, right?

03:17 I'm gonna 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 gonna search, oh, it's kinda hard to correlate, right?

03:25 So what you do is you install, into your app, you install a socket handler as one of the trace sources.

03:33 And then you just, this just listens to that UDP source.

03:36 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.

03:48 - Yeah, and change the color on them and stuff.

03:50 - It's got a dark mode, you know it's for developers.

03:52 (laughing)

03:53 - Yeah.

03:54 - Yeah, but quick shout out to just the framework, though.

03:57 It is based on PyQt 5, and it's all open source, so you can go check it out and see how they built it.

04:03 It's a pretty decent looking app.

04:04 - 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.

04:14 - It's pretty cool.

04:15 So it allows any number of simultaneous connections, so you can have different people can watch it.

04:21 You can change the look of the field, you can filter like you said, you can search, you can view exceptions and tracebacks and stuff on separate windows.

04:28 So you can like pop out the traceback and just look at the details.

04:31 It's pretty cool.

04:32 - Yeah, okay, neat.

04:33 - Yeah, very nice.

04:34 So there's a really cool CMS for Python called Wagtail, right?

04:39 - 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?

04:53 - Like Squarespace, something like that.

04:55 Drupal, Drupal.

04:57 - Drupal, that's it, yeah.

04:58 There is one for, actually I think there's several for Python, but Wagtail is one of the more popular ones.

05:04 And it's got a really nice look.

05:06 And 2.0 just came out, and they're pretty excited about it.

05:11 We did cover Django 2.0 changes recently, and this Wagtail 2 does support Django 2.

05:18 And there's apparently a better, newer text editor that they're excited about, and some fixes in scheduling your published content.

05:28 - Yeah, it's awesome that it's based on Django 2.

05:31 And of course that means goodbye Legacy Python as well, right? - Yeah.

05:35 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.

05:50 But they do have a couple things to help.

05:52 There's a, we're going to link to both of these.

05:54 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.

06:02 And some of them are professional and they look really nice.

06:05 - Yeah, they do look really nice.

06:06 And like the whole, what one is it?

06:08 It's the Royal College of Art in London.

06:12 Its entire site is driven by Wagtail.

06:14 - Wow, that's nice.

06:15 And then there's a couple of e-commerce sites that are in there too.

06:18 So you can set up e-commerce as well.

06:20 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.

06:34 So, that's neat.

06:35 - I like it that they have that kind of philosophical guidance to help you to go along.

06:38 It's cool.

06:39 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.

06:48 - Yeah, actually, I think I'm gonna set up something for work using Wagtail just to try it out.

06:52 - Yeah, super nice.

06:54 So speaking of setting up stuff, let me tell you about DigitalOcean.

06:56 So with DigitalOcean, you know, 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?

07:09 Do you want WordPress?

07:10 Then you gotta go set that up.

07:11 You want Django?

07:13 You've gotta like make sure Python's installed and all the things are all set up and whatnot.

07:17 That doesn't even mention the database, right?

07:19 So one of the cool things that they have that I wanna highlight is they have the ability 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 to 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 to go server, boom, it's up and running. You want to 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 have 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 a your own team GitHub like thing so yeah, that's the super cool. You don't need to know that much about it, right?

08:07 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 Thanks. All right. Yeah, so check them out at do dot 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.

08:22 What's the most popular way of accessing databases, you think?

08:26 What would you use?

08:26 - Raw SQL statements.

08:28 - I'm sure it's the most popular.

08:30 But outside of that, I'm thinking like Django ORM, SQLAlchemy, like these are the major tools, right?

08:37 - Yeah, ORMs.

08:38 - Yeah, the ORMs.

08:39 So there's another one that's really cool, that's really small and lightweight called PeeWee.

08:42 You would never know by the name.

08:44 - It's a good name, actually.

08:46 - It is a good name.

08:47 So it's a simple and small ORM.

08:50 It has a few but very expressive concepts to make it easy to learn, intuitive to use, and so on.

08:55 Right, that's what they say about it.

08:57 It's been around for a while, but the news is they did a complete rewrite of it and released PUE 3.0.

09:03 - Nice.

09:04 - Yeah, so it's pretty cool.

09:05 It has, it's developed with Python 3.6, so it like embraces all those features.

09:10 It has built-in support for SQLite, MySQL, and Postgres.

09:13 Those are all nice.

09:14 and then has extensions for things like full-text search and migrations and whatnot.

09:19 So that doesn't sound so PeeWee, actually that's a lot of features.

09:22 So a lot of cool stuff.

09:23 One of the reasons it's really interesting to me is 'cause there's a separate project called PeeWee Async.

09:29 One of the challenges you have doing any Async stuff is everything that is blocking or slow has to be Async or there's kind of no point to even getting started, right?

09:38 If I'm gonna call a web service, I have to use the Async, the AIO HTTP client or it just doesn't make sense, right?

09:44 It's just blocking, like there's no async behaviors.

09:47 And you run into that problem often with accessing databases, like say SQLAlchemy and stuff.

09:52 So this thing, PUE_ASYNC, will let you add async ability to your queries.

10:00 So it's super cool.

10:01 So you can go, if you want to insert something, you would just say like await objects.create, and you pass off the object you're gonna insert into the database.

10:08 You wanna do a query, you just say like all objects equals await objects.execute, like your, like in the syntax.

10:16 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.

10:24 - That's pretty cool, neat.

10:25 - Yeah, so I'm pretty excited to see them doing this.

10:27 This is really cool.

10:28 All right, not a whole lot more.

10:29 I just, 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, 'cause I think Django and SQLAlchemy get most of the sunshine.

10:38 So I told you that digitalization, you can go push that button and create a machine learning thing, but what if you don't know about machine learning?

10:43 >> Which, I'm kind of in that camp.

10:45 I know most of the buzzwords, but I haven't really done much work in it.

10:49 So I was excited to see that there was somebody that put up a repo, a GitHub repo, called Machine Learning Basics.

10:58 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.

11:11 Because in production, you've got all these fancy server tools that you can use to make things really fast.

11:18 But if you're just trying to understand the concepts, I want to see the code.

11:24 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.

11:33 How would you do doesn't mean to do linear regression or logistic regression or k means clustering or nearest neighbor.

11:41 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 be 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.

12:03 And yeah, it's just pure Python, right?

12:04 It's not like, oh, you call this thing a TensorFlow, then magic, magic things happen, right?

12:09 It really shows you the steps, so quite nice.

12:11 - Right, I mean, when I'm just learning stuff, and I don't need it to be fast, I just, and I don't need to hook up to TensorFlow right away.

12:18 I don't even, I just want to know more about this stuff.

12:21 This is a great thing.

12:22 - Yeah, definitely cool. - So good job.

12:23 - Yeah, well done, and if you're getting started in that, definitely check that link out.

12:28 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 Hiroshi. 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.

13:25 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.

13:35 Sorry, there's a problem or set of problems.

13:37 One of them is the age and the min value is 10, but you gave five.

13:40 Okay, what do you pass it?

13:41 Is it JSON or?

13:42 No, it's just a dictionary.

13:43 Okay.

13:44 Yeah, so it looks very JSON-y, but you just give it any dictionary.

13:47 And so anytime you're reading data that comes in in a dictionary form, and you want to validate it.

13:52 This is a really rich and extensible way to do that, right?

13:56 So, quite cool.

13:58 - That's a great way to write at your API level to make sure that bad data doesn't go down to the rest.

14:04 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.

14:11 - Absolutely, like these fields are required, it has to be this format.

14:13 You don't have to go, "Okay, well, "I know it comes in a string, "can I convert it to an integer?" No, that's an exception.

14:18 Okay, so then I'm going to capture that error and save it back, right?

14:21 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.

14:29 It's really, really nice.

14:30 Nice and really very cool that you put that as a separate project so that other projects can use it.

14:35 Exactly.

14:36 So this is used in the E framework, which is a restful framework based on Flask and Mongo.

14:41 But instead of baking that into the framework, it's like I'm going to create this validation thing which is totally separate.

14:45 It makes sense to be used wherever.

14:48 But it just also happens to be the validation layer in the REST framework.

14:52 So quite cool.

14:53 Yeah, very, very neat.

14:54 All right.

14:55 Thanks for all the cool things you found.

14:56 Yeah, thank you.

14:57 Bye.

14:58 Hey everyone, just a quick bit of news before we get out of here.

15:02 When Brian and I recorded, I didn't have anything to share, so we didn't talk about it.

15:06 Since then, I've just launched a new course over at Talk Python Training, and it's called 100 Days of Code with Python.

15:13 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

15:26 Thank you for listening to Python Bytes.

15:28 Follow the show on Twitter via @pythonbytes, that's Python Bytes as in B-Y-T-E-S.

15:34 And get the full show notes at

15:37 If you have a news item you want featured, just visit and send it our way.

15:42 We're always on the lookout for sharing something cool.

15:44 On behalf of myself and Brian Okken, this is Michael Kennedy.

15:48 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page