Transcript #352: Helicopter Time Comes to Python
Return to episode page view on github00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to earbuds.
00:05 This is episode 352 recorded September 12th, 2023. I'm Michael Kennedy.
00:11 And I'm Brian Okken.
00:12 And this episode is sponsored by us, supported by us, support the podcast by choosing our courses, listening to our podcasts, including the new one by Brian, Python People, and the Patreon supporters and find us on fostedon.org.
00:29 Brian, me, and the show, the links in the show notes, and also the show notes have how to attend the live session if you want.
00:37 - Yes.
00:38 - Brian, when do you got to start our day here?
00:40 - I feel like it's the start of school, so I feel like a helicopter parent.
00:45 - No, that's right.
00:46 You got your homework done?
00:48 Was anyone mean to you?
00:49 Can I help you out, sweetie?
00:50 (laughing)
00:51 - So the first topic is called Heliclockter, And it is, like, apparently it's a pun on helicopter parenting, maybe?
01:00 I don't know.
01:01 So, like helicopter, but clock, get it?
01:06 Kind of a heliclock.
01:08 So this was submitted by Peter Nielsen.
01:10 I think he was involved in this, but the idea is, it's like date times, but they're a little bit better.
01:19 So apparently one of the frustrations that this group had was with normal date times, they looked into other things, is being able to just have a date time where you can just enter the time, but have it be aware of what time zone it's in. So the big thing about this is a subclass of date time with some extra features. So you've got a date time TZ, which is a time zone aware date time, and then you've got a local one, which ensures that the time zone is local time and then a UTC.
01:54 There are some other solutions out there that deal with, just assume UTC plus zero, but that's often not convenient.
02:03 I guess one of the things they had was they wanted to be able to have daytime items as objects and then be able to sort them, but have them keep, maintain what time zone they were created in and stuff, which is an interesting thing.
02:18 It looks just like working with time zones.
02:21 So it looks pretty easy to work with if you've ever worked with time zones.
02:25 They do have some other cool features like statically type-checkable and pedantic integration, which is neat.
02:32 Anyway, they've got also an article about why they created it.
02:39 Time flies when you're having zones.
02:41 Nice. So it's a pretty interesting discussion going through why they chose the solution they did of creating their own and everything.
02:51 Being able to use it with mypy also is kind of cool.
02:54 >> Yeah.
02:55 >> Yeah.
02:56 >> Neat time zone.
02:56 >> Shout out to Arrow and Pendulum as well, or some of the other well-known ones.
03:00 >> Yeah. Even at daytime UTC they found, but it's UTC zero.
03:06 Then they even talked about how they designed it and why.
03:10 Their first thing was just create a completely new type, But then they came up with some problems with that.
03:16 So they came up with subclassing.
03:18 So then these new types are types of date/time also, so you can use other things to go with them.
03:25 So I think that's a cool solution.
03:27 I'm not usually a fan of subclassing, but I think the subclassing in this case makes a lot of sense.
03:32 Anyway, what you got for us?
03:35 - That looks good.
03:36 I think it sounds so easy to be working with time, but it's always so tricky.
03:42 I have something keeping with the same color scheme here, a new release for Wagtail.
03:48 And I don't believe we've talked about Wagtail before.
03:50 It's possible.
03:52 I did get a chance to use our search today, you know, and just reminded how nicely that goes.
03:59 I guess we talked, at least mentioned it somewhere, but Wagtail is a CMS, the leading open source Python CMS built on Django, but you don't necessarily have to know Django.
04:12 It's kind of like WordPress in the sense that you could just go through the setup steps and run WordPress and not even worry about the fact it's written in PHP.
04:20 So Wagtail is a little bit like that, but just pip install Wagtail to go get going.
04:26 And it's got some really cool features.
04:27 I haven't really explored it too much, but it's got this really cool visual designer for people to build out web pages and stuff.
04:33 Isn't that cool?
04:34 So you can like hit a little plus and get like a nice whizzy wig.
04:38 I'm gonna insert a heading or insert a table or like a image gallery with these images.
04:44 It has a cool tree structure so you can organize your content.
04:48 And because it's Django, you can extend it doing Django things, which is pretty sweet.
04:53 And it has a bunch of, you can make little snippets that you can use inside your pages.
04:57 So that's pretty neat.
04:58 And it even has a library for managing your images.
05:01 So pretty cool stuff.
05:03 And the news item today is an article by Megan Voss.
05:07 come over to the dark side with a Wagtail 5.
05:10 So Wagtail 5.0 is a new release here with a bunch of cool things.
05:16 So dark mode, if you want your website, which is backed by Wagtail to have dark mode, well, dark mode is a thing, which is pretty excellent.
05:23 I'm a big fan of dark mode.
05:25 It has SVG image support in addition of scalable vector graphics, in addition to just JPEGs and stuff.
05:32 It has an accessibility, an enhanced accessibility checker.
05:35 That's pretty cool.
05:36 If you're creating content and it's hard for people who have to use screen readers or something, it can tell you that you're not doing that.
05:42 Like, missing paragraphs is heading.
05:44 I miss using paragraphs as headings, use proper tags, incorrect heading hierarchy, avoid skipping levels.
05:50 Oh, wow.
05:50 And you know, things like that.
05:52 Right.
05:52 But yeah, certainly my, my handwritten stuff.
05:55 That's only, you know, if I remember that, that's how it's supposed to go.
05:57 Right.
05:58 So pretty sweet.
05:59 What's wrong with five H ones on one page.
06:01 No, I know.
06:03 I really, I really have a lot to say here.
06:05 so it's all H1s. It also has, what is the, when you, if you want to delete, like say you have an image or something, it's in your gallery and you're like, ah, not going to use this after all, hit delete. It keeps track of if it's used in any other pages, so you don't accidentally delete something that's being used in some part of the site you didn't know about that someone else created. That's pretty awesome. More snippets, more validation, and they threw away a bunch of old code so they can work better, which, you know, may even have a blog post on addressing technical debt.
06:37 But so few breaking changes, not too many, but yeah, check it out.
06:40 Anyway, Wagtail looks pretty awesome, right?
06:42 I think I may have talked about a long time ago, but anyway, not the 5.0 release because that's quite recent.
06:47 Yeah, I think it's it's pretty cool that that's there.
06:50 And I do have plans to play with it at some point, but I've had plans to play with it for a while.
06:55 So indeed, Kim, the audience says, I know several one person technical businesses that really like Wagtail for their sites.
07:03 easy to use for technical, competent users, but doesn't require much of their time to maintain.
07:07 Yeah, that seems great.
07:08 Yeah, nice.
07:09 Over to you.
07:10 Well, I guess I go away from Python a little bit, but we use it all the time.
07:17 So I want to talk about Git.
07:19 So I don't think I use any other revision control systems anymore other than Git.
07:26 No CVS?
07:27 No.
07:28 No clear-C?
07:29 No good stuff?
07:30 Of course.
07:31 Subversion, actually I touch on subversion once in a while.
07:36 But--
07:36 - I still have kind of good feelings towards subversion.
07:38 The other ones make me a little queasy.
07:41 - Anyway, the thing that I often wanna know is just like the stuff that happened recently on a file or something, or just on a Git repository.
07:50 RCS, Mike Felder, oh, Fiedler, sorry.
07:54 Nice, RCS, wow.
07:56 Takes me back.
07:58 But so get one of the things is to get log.
08:02 So looking at what's happened recently, but the the get log output is not something I like to do.
08:09 Actually using get log is one of the reasons why I often pop up like a visual tool to look at my get repository because it's gross.
08:19 But I forgot I and I know I knew that you could customize it, but I kind of forgot how how to, so I haven't been, but this now I have because of this article.
08:28 So there's an article called Get Log Customization from Justin Joyce.
08:32 And so the default is something like that, which we're showing.
08:35 It's got a really long hash number and a bunch of information, but it's hard to find the information you need.
08:42 One of the things that Justin points out is that you can do just something really easy by passing in one line.
08:51 just the flag, the done, like two dashes and one line, all one word, will make it pretty nice actually.
09:00 It just does a short hash and you can kind of see what's going on a little bit better, but it goes a lot further.
09:07 And I'm gonna hop down to this really cool customization.
09:09 One of the things is using graph.
09:13 Graph is great, --graph, so that you can see kind of, it does like kind of a visual representation the different, what are those?
09:22 >> The branches and the merges.
09:24 >> Branches, that's it. I always forget branches and branch or fork.
09:27 >> And ASCII art for the win there.
09:29 >> Yeah, ASCII art.
09:30 But then you can do color and stuff.
09:32 So the graph does color also if you have that on everything.
09:39 But it also talks about how the one line is actually a combination of pretty one line and abbreviate commit, which is cool.
09:51 Then what I really love is this thing that he comes up with at the end.
09:57 I didn't know that you could put aliases in the Git config file, or at least I did once and I forgot about it.
10:04 But this is a pretty cool long alias.
10:07 He's got LG instead of log.
10:09 Save a character of typing right there.
10:12 But it defaults to, so it's an alias for log with a graph with 10, so default to the last 10 commits.
10:20 Then this long format thing that is ugly to look at, but what you get, he talks about what it all is, but what you get is the graph, but you also get somebody's name highlighted of who did it, and then also how long ago.
10:38 Was it 19 hours ago, or 24 hours ago, or two days?
10:42 three days, really cool.
10:44 Exactly what I need usually when I'm looking at a Git log.
10:47 >> I love it. This actually inspires me to maybe play with this as well.
10:51 I usually use SourceTree.
10:53 I really like SourceTree, but sometimes you're already in the terminal and just.
10:58 >> Yeah. What I did is I just opened up my home directory Git config and added this alias, and now I just use Git-LG.
11:07 Then I can forget all of this.
11:09 One of the neat things, I'm like, well, if it says by default, you can put the default whatever you want for this alias, but 10 lines, what if I want to see 20 lines or 30 lines?
11:19 Well, if you say getLG, even though it has the -10 built into it and pass in a -20 or -30, the second one overrides it.
11:29 >> That's clever.
11:30 >> Works just fine. So nice.
11:32 So thank you, Justin Joyce, for writing this up.
11:36 >> Nice job, Justin. That's pretty awesome.
11:39 All right. I saw that David Lord was the one listed there in the example.
11:44 Yeah.
11:44 Let's keep going with that theme.
11:46 Okay.
11:46 So over to historically from the Flask side of things.
11:51 So I want to talk about Flask.
11:53 I want to talk about Jinja.
11:55 So Jinja is the templating language that is the default for so many frameworks.
12:01 It's not best, I don't think.
12:03 Come on, Chameleon.
12:04 So much better.
12:06 But it doesn't matter if everyone's using Jinja, like that's what people are using, right?
12:11 It's built into all the frameworks.
12:12 You gotta jump through hoops to like use Chameleon with say FastAPI, right?
12:17 Like I created a library to do that kind of stuff.
12:18 But this is about Jinja and its origins come from Flask, originally created by Armin Roeniger, no longer the maintainer, David Lord and folks over at Palettes is.
12:29 But this new project I wanna give a shout out to does come from Armin and it's called Mini Jinja.
12:35 Like Jinja, but smaller.
12:38 So MiniJinja is a powerful but minimal dependency template engine for Rust that's compatible with Jinja and Jinja 2.
12:45 So if you've got a Rust project and you want to have those templates, you could use this and you'd be like, "Okay, might go well." Python podcast. So yeah, Rust's popular, but it's comparable if you've got a Python app.
12:57 It's basically not 100% identical, but pretty similar, right?
13:02 The other thing though, that's kind of interesting is, it does works with Python through this project called mini-ginja-py, and that allows you to use the Rust runtime-backed template engine on whatever thing it is that you're working with.
13:20 Flask, FastAPI, whatever.
13:22 So, you might want to use this.
13:24 Instead, when the full set of Ginja 2 features is not required, is not required and you want to have the same experience across Python or Rust.
13:32 There's places where you can get a slightly better performance sometimes than Jinja.
13:38 It was created using maturing and Pi 03, which is pretty cool, like the Rust Python bindings.
13:46 Yeah, it just shows you how to set up and whatnot.
13:48 So if you're out there doing the web things, maybe have a quick look at Mini Jinja if somehow that's relevant to you.
13:55 >> Continuing the rustification of Python.
13:58 >> Indeed. You know it's been around for a long time, over 30 years, so surely some rust is starting to develop.
14:04 I wouldn't have expected to come on so quickly all at once like that, but there you go.
14:08 >> Yeah, nice.
14:10 >> That's it for all of our items, I would say.
14:12 >> Okay.
14:13 >> I've got some extras, but I know you do too, so maybe you go first.
14:17 >> Okay. Well, we were just talking at the beginning of this, before we went on air, that I was having some audio trouble last night, but I was getting the pytest primary power course ready and launched last night.
14:32 So chapter six, got done recording that yesterday morning and in the evening finished editing the audio.
14:38 So the first course in a series, pytest primary power, and to sell, so what does it cover?
14:44 It covers test functions, fixtures, built-in fixtures, parameterization markers, and it's really the set of things I think that you have to know to be able to be using pytest effectively.
14:55 You could just take this first course and I think run with it for quite a long time.
14:59 So to celebrate getting it done and back to school, I know everybody's with kids.
15:04 The kids are probably started last week or the week before.
15:08 - It might sound like it's for school, but now the kids are out of the house.
15:11 You actually have time and energy to study things again.
15:14 That's my house anyway.
15:15 - Yeah, yeah.
15:17 So I'm offering a deal for it.
15:19 So 49 bucks for the first course and if you wanna do the bundle, $99.
15:25 And the bundle's kind of fun because I've already had some, we've got a lot of channels to get feedback.
15:30 I had some feedback this last night and this morning saying, "Hey, I'm trying this on Python 3.8 "and it doesn't work." But it does now.
15:39 So this morning I did the, it was like the from future import annotations I had to do to make the annotations from 3.10 be compatible to Python, way back to Python 3.7.
15:50 So I tested it on 3.7 this morning.
15:52 So everything should be working.
15:54 So anyway, pretty excited about that.
15:56 - Excellent, yeah, congratulations.
15:58 That's a big step.
15:59 - If you see something like this, you're in the right place.
16:01 So thanks.
16:02 How about you?
16:04 - That's the testing code logo.
16:05 Enroll in the course for 49 bucks, awesome.
16:08 Keeping with the course theme a little bit, I have three new courses coming out at Talk Python Training.
16:15 We have a new HTMX plus Django course, which is gonna be excellent.
16:20 A new language-based course without more detail on that.
16:23 and one or two data science courses coming in quite soon.
16:28 And since it's a bunch of things, all of them not quite released yet, just point people at training.talkpython.fm/getnotified and there, if you're not already in the mailing list, put your name and email in here and you'll get to hear about them or keep listening to the podcast.
16:46 I'm sure I'll talk about it then as well.
16:48 I also just wanna give a shout out to Cloudflare Turnstile.
16:51 I've been going through and classifying trucks, cars, crosswalks, stoplights.
16:58 Holy moly.
16:59 What a dreadful unnecessary thing.
17:02 So way back in three or four, you know, October, 2022, I talked about turnstile, which is a privacy friendly, private, user-friendly privacy, perversing and preserving.
17:16 Alternative to recapture and all those things.
17:18 And it just sits down here.
17:20 And while we're waiting, you know how, like sometimes if you are slow filling out a form, it'll say your selection of taxis has expired and you got to do it again, this one automatically, I saw it while I was waiting for you to talk about your new course and bundle.
17:35 That thing just did a little flicker and regenerated its validation with no user input, just in the background.
17:41 Telling you.
17:42 Come on.
17:42 So how does it know you're not a robot?
17:44 You know, it runs some JavaScript and it also, I think, you know, I don't remember all the details.
17:51 It runs through a bunch of other heuristics that like they know from, I think from your IP address talking to, because you know Cloudflare like fronts something like 25 percent of the internet.
18:01 So they can tell if you're going to a bunch of different sites and things, and it kind of uses that background information, I think.
18:07 Anyway, I have not even had to find a taxi to be able to submit that.
18:12 >> But it's made it so that you don't have a bunch of automated stuff coming in.
18:17 Exactly.
18:17 People used to be hammering on it, doing all sorts of bad stuff.
18:20 Yeah.
18:21 That's not good.
18:22 Yep.
18:22 So, yeah, I'd add it for like the login page.
18:27 and for the, the registration page, a bunch of bots were signing up.
18:31 I'm like, I don't understand why they're signing up because it's a free account and you don't really get anything for free.
18:36 So I couldn't understand why they're all, but hundreds of them were signing up.
18:39 Okay.
18:40 I'm kind of do something.
18:41 And then, this is an improvement over recapture.
18:43 All right.
18:45 Pie Bay, Pie Bay is coming up October 8th.
18:48 I will be there speaking about Python type hints and how you can super power your apps, something like five amazing ways and tools you can use with your apps, I believe is what my topic is roughly supposed to be, but I will be there and, people can, they happen to be in the San Francisco area or area or wanting to be there.
19:08 They can check it out.
19:09 They gave me a coupon, say friend of speaker.
19:13 If you use that friend of speaker, no spaces, you get 20 percent off regular tickets.
19:16 So that's always fun.
19:18 >> Nice.
19:18 >> Yeah. Always a fun trip, a road trip down to San Francisco.
19:22 Let's see, following up on your doc strings.
19:25 We got some really nice follow-up here, Brian.
19:27 Rhett Turnbull says, "With regard to the doc strings article Brian covered last episode, the Google format allows for a raises section." Remember I said, "Oh, it'd be awesome if you could say actually what errors could happen." >> Yeah.
19:41 >> That's really cool. Rhett uses Google DocString format for projects, type hints, descriptive variable names, MKDocs and MKDocs strings, get pretty docs for free, and VS Code will pull DocString so you can see them in the editor, and Copilot practically writes the DocStrings for you, which is excellent.
19:58 And one second, attribution.
20:01 John Hagen sent over something saying pretty similar, say, remember we said, look, you don't necessarily need to include the type in the DocString if there's a type hint, and sure enough, you don't have to.
20:11 - Oh, cool.
20:12 it a description, which is cool, and also points out the syntax for how you use the raises. So you say raises and you give it a list of exception types, and then the description of when the scenarios when that might happen. So for example, raises invalid factorial error if n is less than zero is the time that that happens.
20:30 >> Oh, cool.
20:31 >> Isn't that cool?
20:32 >> Yeah.
20:33 >> Yeah. And finally, John also points out that iCharm has the integration for Google strings somewhere in here.
20:42 Yeah.
20:42 for Google doc format and how to set that up.
20:45 So it'll, it'll automatically auto complete and render Google doc strings.
20:50 When you say, give me the quick help, I control Q and it'll like, just pop that up as a rendered sort of thing there.
20:56 So a lot of followup on the doc strings.
20:58 Awesome.
20:59 Cool.
20:59 Yeah.
21:00 And that's all I got for my extras about a joke.
21:03 What do you think?
21:03 Yeah.
21:04 Ready?
21:04 I've got your joke and then I want to do a dad joke also after that.
21:08 Awesome.
21:09 So this one is a lesson in optimization.
21:11 Careful what you measure careful what you asked for.
21:14 Right.
21:14 So there's this picture of two tennis ball containers.
21:18 You know, those tubes that are vacuum sealed.
21:20 Yeah.
21:20 One of them is not at all optimized.
21:23 It stores only three tennis balls, but the one to the right says, look, if you cut the tennis balls in half, you can, you can store six tennis balls in this container.
21:33 Way more efficient use.
21:35 Yeah.
21:36 Yeah.
21:37 I mean, your tennis game might suck, but that's awesome.
21:40 Yeah.
21:41 Yeah.
21:41 So there you have it.
21:42 Yeah.
21:43 Okay.
21:44 So over to you to close it out.
21:45 I've got a joke that I just, I was reminded of the other day with, at shared with my kid, it's told dad joke.
21:52 So, have you seen birds fly in a V formation before?
21:56 Sure.
21:56 have you ever noticed that sometimes that one side is a lot longer than the other, or it's longer than the other?
22:01 Yeah.
22:02 Do you know why that is?
22:03 There's more birds.
22:04 >> Optimize it. Amazing.
22:08 >> Anyway. It's terrible.
22:11 >> I love it. Perfect dad joke.
22:14 Well, perfect episode as well. Thanks for being here.
22:17 >> Thank you.
22:18 >> Thanks everyone for listening.
22:19 >> Yeah.