Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to earbuds.
This is episode 352, recorded September 12th, 2023. I'm Michael Kennedy.
And I'm Brian Okken.
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 Fostadon.org. Brian, me, and the show.
The link's in the show notes. And also, the show notes have how to attend the live session, if you want.
Yes.
Brian, what do you got to start our day here?
I feel like it's the start of school, so I feel like a helicopter parent.
That's right. You got your homework done? Was anyone mean to you? Can I help you out, sweetie?
So, the first topic is called Heliclockter. And it is, like, apparently, it's a pun on helicopter parenting, maybe? I don't know.
So, like, helicopter, but clock, get it? Kind of a helicopter.
So, this was submitted by Peter Nielsen. I think he was involved in this, but the idea is, it's like date times, but they're a little bit better.
So, apparently, one of the frustrations that this group had was with normal date times, and they looked into other things,
is being able to just have a date time where you can just enter, like, the time, but have it be, like, 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.
So, there are some other solutions out there that deal with just assume UTC plus zero, but that's often not convenient.
And I guess one of the things they had was they wanted to be able to have date time items as objects,
and then be able to sort them, but have them keep, like, maintain what time zone they were created in and stuff,
which is kind of an interesting thing.
So, they've got, it looks just like working with time zones.
So, it looks pretty easy to work with if you've ever worked with time zones.
They do have some other cool features, like statically type checkable and Pydantic integration, which is kind of neat.
Anyway, they've got also an article about why they created it.
Time flies when you're having zones.
Nice.
So, it's a pretty interesting discussion going through why they chose the solution they did of creating their own and everything.
And being able to use it with mypy also is kind of cool.
So, yeah.
Yeah.
Neat time zone.
Shout out to Arrow and Pendulum as well, or some of the other well-known ones.
Yeah.
Even a Datetime UTC they found, but it's UTC zero.
And then they even talked about why that, like, how they designed it and why.
So, their first thing was just create a completely new type, but then they, you know, came up with some problems with that.
So, they came up with subclassing.
So, then these new types are types of Datetime also.
So, you can use other things to go with them.
So, I think that's a cool solution.
I'm not usually a fan of subclassing, but I think the subclassing in this case makes a lot of sense.
Anyway, what you got for us?
Yeah.
That looks good.
You know, I think it sounds so easy to be working with time, but it's always so tricky.
Yeah.
I have something keeping with the same color scheme here, a new release for Wagtail.
And I don't believe we've talked about Wagtail before.
It's possible.
I, I did get a chance to use our search today, you know, and just reminded how nicely that goes.
I guess we've talked to at least mention it somewhere.
But Wagtail is, a CNS, the CMS, the leading open source Python CMS built on Django, but you don't necessarily have to know Django.
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.
So Wagtail is a little bit like that, but just pip install Wagtail to go get going.
And it's got some really cool features.
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.
Isn't that cool?
So you can like hit a little plus and you get like a nice WYSIWYG.
I'm going to insert a heading or insert a table or, like a image gallery with these images.
It has a cool tree structure so you can organize your content.
And because it's a Django, you can extend it doing Django things, which is pretty sweet.
And it has a bunch of, you can make little snippets that you can use inside your pages.
So that's pretty neat.
And it even has a library for managing your images.
So pretty cool stuff.
And the news item today is an article by Megan Voss.
Come over to the dark side with Wagtail five.
So Wagtail 5.0 is a new release here with a bunch of cool things.
So dark mode, if you want your website, which is backed by Wagtail to have dark mode, well, dark mode is a thing.
It's pretty excellent.
I'm a big fan of dark mode.
It has SVG image support in addition for scalable vector graphics.
In addition to just JPEGs and stuff.
It has an accessibility and enhanced accessibility checker.
That's pretty cool.
Like 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.
Like missing paragraphs as headings, misusing paragraphs as headings, use proper tags, incorrect heading hierarchy, avoid skipping levels.
Oh, wow.
And, you know, things like that.
Right.
Which is certainly my handwritten stuff.
That's only, you know, if I remember that that's how it's supposed to go.
Right.
So pretty sweet.
What's wrong with five H1s on one page?
I know.
I really, I really have a lot to say here.
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 and it's in your gallery and you're like, ah, I'm not going to use this after I'll 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.
But so a few breaking changes, not too many, but, you know, check it out.
Anyway, Wagtail looks pretty awesome, right?
I think I may have talked about it a long time ago, but anyway, not the 5.0 release because that's quite recent.
Yeah.
I think it's pretty cool that that's there.
And I do have plans to play with it at some point, but I've had plans to play with it for a while.
So anyway.
Indeed.
Kim out in the audience says, I know several one-person technical businesses that really like Wagtail for their sites.
Easy to use for technical competent users, but doesn't require much of their time to maintain.
Yeah, that seems great.
Yeah.
Nice.
Over to you.
Well, I guess I go away from Python a little bit, but we use it all the time.
So I want to talk about Git.
So I don't think I use any other revision control systems anymore other than Git.
No CVS?
No.
No CVS?
Any of that good stuff?
Of course.
Subversion.
Actually, I touch on subversion once in a while.
I still have kind of good feelings towards subversion.
The other ones make me a little queasy.
Anyway.
The thing that I often want to know is just like the stuff that happened recently on a file or something or just on a Git repository.
RCS.
Mike Felder.
Oh, field.
Fiedler.
Sorry.
Nice.
RCS.
Wow.
Takes me back.
But so one of the things is to Git log.
So looking at what's happened recently.
But the Git log output is not something I like to do.
Actually, using Git log is one of the reasons why I often pop up like a visual tool to look at my Git repository because it's gross.
But I forgot and I knew that you could customize it, but I kind of forgot how to.
So I haven't been.
But this now I have because of this article.
So there's an article called Git log customization from Justin Joyce.
And so the default is something like that, which we're showing.
It's got a really long hash number and a bunch of information, but it's hard to find the information you need.
One of the things that Justin points out is that you can do just something really easy by passing in one line.
Just the flag, like two dashes in one line, all one word, will make it pretty nice, actually.
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.
And I'm going to hop down to this really cool customization.
One of the things is using graph.
Graph is great.
--graph so that you can see kind of it does like kind of a visual representation of the different.
What are those?
The branches and the merges.
That's it.
I always forget branches and branch or fork.
No, it's an ASCII art for the win there.
Yeah, ASCII art.
But then you can do like color and stuff.
So there's the graph does color also if you have that on everything.
It talks about how he also talks about how the one line is actually a like a combination of pretty one line and abbreviate commit, which is kind of cool.
And then what I really love is this the thing that he like comes up with at the end so that I didn't know that you could put aliases in the get config file.
So or at least I did once and I forgot about it.
But this is a pretty cool long alias.
He's got LG instead of log.
So save a character of typing right there.
But it defaults to.
So it's an alias for log with a graph with 10.
So default to the last 10 commits.
And then this long format thing that is kind of ugly to look at.
But what you get is he talks about what it all is, but what you get is the brand, the graph.
But you also get somebody's name highlighted of who did it.
And then also how long ago.
So was it 19 hours ago or 24 hours ago or two days, three days?
Really cool.
Exactly what I need usually when I'm looking at a get log.
So I love it.
This actually inspires me to maybe play with this as well.
I usually use source tree.
I really like source tree.
But, you know, sometimes you're already in the terminal and just, you know.
Yeah.
And so all I did, what I did is I just like opened up my home directory, get config and added this alias.
And now I just use get LG.
That's and then I can forget all of this.
The other 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 like 10 lines.
What if I want to see like 20 lines or 30 lines?
Well, if you say get LG, even though it has the dash 10 built into it and pass in like a dash 20 or dash 30, the second one overrides it.
So that's clever.
Works just fine.
So nice.
So thank you, Justin Joyce, for writing this up.
Nice job, Justin.
That's pretty awesome.
All right.
I saw that David Lord was the one listed there in the example.
Yeah.
Let's keep, let's keep going that theme over to historically from the flask side of things.
So I want to talk about flask.
I want to talk about Jinja.
So Jinja is the template language that is the default for so many frameworks.
It's not best.
I don't think come on chameleon.
So much better.
But it doesn't matter if everyone's using Jinja.
Like that's what people are using.
Right.
It's built into all the frameworks.
You got to jump through hoops to like use chameleon with say FastAPI.
Right.
Like I created a library to do that kind of stuff.
But this is about Jinja and its origins come from flask originally created by Armin Roeneker.
No longer the maintainer, David Lord and folks over at pallets is.
But this new project I want to give a shout out to does come from Armin and it's called mini
Jinja.
Like Jinja, but smaller.
So mini Jinja is a powerful, but minimal dependency template engine for rust.
That's compatible with Jinja and Jinja2.
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, Michael.
Well, a Python podcast.
So yeah, rust is popular, but it's comparable.
If you've got a Python app, it is basically not a hundred percent identical, but pretty similar.
Right.
The other thing though, that's kind of interesting is it does works with Python through as project
called mini Jinja dash pie.
And that allows you to use the rust runtime backed template engine on whatever thing it
is that you're working with.
Right.
Flask FastAPI, whatever.
Right.
So you might want to use this instead when the full set of Jinja2 features is not required
and you want to have the same experience across Python or rust.
There's places where you can get a slightly better performance sometimes than Jinja.
It was created using maturing in py03, which is pretty cool.
Like the rust Python bindings.
And yeah, it just shows you how to set up and whatnot.
So if you're out there doing the web things, you know, maybe have a quick look at mini Jinja.
If somehow that's relevant to you.
Continuing the rustification of Python.
Indeed.
You know, it's been around for a long time, over 30 years.
So surely some rust is starting to develop.
I wouldn't have expected to come on so quickly all at once like that.
But there you go.
Yeah.
Nice.
That's it for all of our items, I would say.
Okay.
And I've got some extras, but I know you do too.
So maybe you go first.
Okay.
Well, I was up.
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.
So chapter six, got done recording that yesterday morning and in the evening, finished editing the audio.
So the first course in a series, pytest Primary Power.
And so what does it cover?
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.
You could just take this first course and I think run with it for quite a long time.
So to celebrate getting it done and back to school.
I know everybody's with kids.
Kids are probably started last week or the week before.
It might sound like it's for school, but now the kids are out of the house.
You actually have time and energy to study things again.
That's my house anyway.
Yeah.
So I'm offering a deal for it.
So 49 bucks for the first course.
And if you want to do the bundle, $99.
And the bundle is kind of fun because I've already had some, we've got a lot of channels to get feedback.
I had some feedback this last night and this morning saying, hey, I'm trying this on Python 3.8 and it's, it doesn't work.
So, but it does now.
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.
So I tested it on 3.7 this morning.
So everything should be working.
So anyway, pretty excited about that.
Excellent.
Yeah.
Congratulations.
That's a big step.
If you see something like this, you're in the right place.
So thanks.
How about you?
The testing code logo and roll in the course for 49 bucks.
Awesome.
Keeping with the course theme a little bit.
I have three new courses coming out at Talk Python Training.
We have a new HTMX plus Django course, which is going to be excellent.
A new language based course without more detail on that.
And one or two data science courses coming in quite soon.
And since it's a bunch of, a bunch of things, all of them not quite released yet.
Just point people at Talk Python 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 when, or keep listening to the podcast.
I'm sure I'll talk about it then as well.
I also just want to give a shout out to Cloudflare Turnstile.
I've been going through and classifying trucks, cars, crosswalks, stoplights.
Holy moly.
What a dreadful, unnecessary thing.
So way back in 304 on October, 2022, I talked about Turnstile, which is a privacy friendly,
user friendly, privacy preserving alternative to reCAPTCHA and all those things.
And it just sits down here.
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.
That thing just did a little flicker and regenerated its validation with no user input,
just in the background.
Telling you.
Come on.
So how does it know you're not a robot?
Do you know?
It runs some JavaScript and it also, I think, you know, I don't remember all the details.
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% of the internet.
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.
But anyway, I have not even had to find a taxi to be able to submit that.
But it's made it so that you don't have a bunch of automated stuff coming in.
Exactly.
People used to be hammering on it, doing all sorts of bad stuff.
Yeah.
That's not good.
Yep.
So, yeah, I had to add it for like the login page and for the registration page.
A bunch of bots were signing up.
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.
So I couldn't understand why they were all, but hundreds of them were signing up.
I'm like, okay, I'm going to do something.
And then this is an improvement over reCAPTCHA.
All right.
PyBay.
PyBay is coming up October 8th.
I will be there speaking about Python type hints and how you can superpower 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 wanting to
be there.
They can check it out.
They gave me a coupon.
It's a friend of speaker.
If you use that friend of speaker, no spaces, you get 20% off regular tickets.
So that's always fun.
Nice.
Yeah.
Always a fun trip, a road trip down to San Francisco.
And let's see, following up on your doc strings, we got some really nice follow up here, Brian.
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.
That's really cool.
And Rhett uses Google doc string format for projects, type hints, descriptive variable names,
MK docs and MK docs strings.
Get pretty docs are free and VS Code will pull doc strings.
So you can see them in the editor and copilot practically writes the doc streams for you, which
is excellent.
And one second attribution.
John Hagan sent over something saying pretty similar.
Say, remember we said, look, you don't necessarily need to include the type in the doc string.
If there's a type hint and sure enough, you don't have to.
Oh, cool.
You can just give 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, and is less than zero is the time that that happens.
Oh, cool.
Isn't that cool?
Yeah.
And finally, John also points out that PyCharm has the integration for Google,
doc strings somewhere in here.
Yeah.
for Google doc format and how to set that up.
So it'll, it'll automatically auto complete and render Google doc strings.
When you say, give me the quick help control Q and it'll like, just pop that up as a
rendered sort of thing there.
So a lot of followup on the doc strings.
Awesome.
Cool.
Yeah.
And that's all I got for my extras.
How about a joke?
What do you think?
Yeah.
You ready?
I've got your joke.
And then I want to do a dad joke also after that.
Awesome.
So this one is a lesson in optimization.
Careful what you measure, careful what you ask for.
Right?
So there's this picture of two tennis ball containers.
You know, those tubes that are vacuum sealed.
Yeah.
One of them is not at all optimized.
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 way more
efficient use.
Yeah.
I mean, your tennis game might suck, but that's awesome.
Yeah.
So there you have it.
Yeah.
Okay.
So over to you to close it out.
I've got a joke that I just, I was reminded of the other day with, shared with
my kid.
It's told dad joke.
So, have you seen birds fly in a B formation before?
Sure.
have you ever noticed that sometimes that one side is a lot longer than the other or
it's longer than the other?
Yeah.
Do you know why that is?
There's more birds.
Optimize.
Amazing.
Anyway, it's terrible.
I love it.
So perfect dad joke.
All right.
Well, perfect episode as well.
Thanks for being here.
Thank you.
Thanks everyone for listening.
Yeah.