Podchaser Logo
Home
#352: Helicopter Time Comes to Python

#352: Helicopter Time Comes to Python

Released Tuesday, 12th September 2023
Good episode? Give it some love!
#352: Helicopter Time Comes to Python

#352: Helicopter Time Comes to Python

#352: Helicopter Time Comes to Python

#352: Helicopter Time Comes to Python

Tuesday, 12th September 2023
Good episode? Give it some love!
Rate Episode

Episode Transcript

Transcripts are displayed as originally observed. Some content, including advertisements may have changed.

Use Ctrl + F to search

0:00

Hello and welcome to Python Bytes where we

0:02

deliver Python news and headlines directly

0:04

to your earbuds. This is episode 352 recorded September 12th, 2023. I'm

0:10

Michael Kennedy. And I'm Brian Ocken. And

0:12

this episode is sponsored by us, supported

0:15

by us, support the podcast

0:18

by choosing our courses. Uh,

0:21

listening to our podcasts, including

0:23

the new one by Brian, Python people and

0:26

the Patreon supporters and find us on fostedon.org.

0:29

Brian me

0:29

and the show links in the show

0:32

notes and also show notes

0:34

have how to attend the live session if

0:36

you want. Yes. Brian, when you

0:38

got to start our day here, I feel

0:41

like it's the start of school. So I think,

0:43

uh, I feel like a helicopter parent. No,

0:45

that's right. You got your homework done. Was

0:48

anyone mean to you? Can I help you out, sweetie? So,

0:51

um, this, uh, the first topic is called heliclockter.

0:55

Um, and it is, it is, uh, like,

0:57

apparently that's a pun on the helicopter parenting,

0:59

maybe. I don't know. Um,

1:02

so, uh, like helicopter, but

1:05

clock get it kind of a heliclock.

1:08

So this was submitted by Peter Nielsen.

1:10

I think he was involved in this, but, uh,

1:13

the idea is, um, is it's

1:15

like, it's like date times, but

1:18

they're a little bit better. So apparently one

1:20

of the frustrations that this group had

1:22

was, um, with date, normal date times, and

1:24

they looked into other things is having,

1:27

being able to just have a date time where you can just enter

1:29

like the

1:29

time, but have it be

1:32

like

1:33

aware of what time zone it's in.

1:35

So it's, um, the, the, the big thing about

1:37

this is, is a subclass of date time

1:40

with, uh, with some extra features. So you've got

1:42

a date time. TZ, which is a,

1:45

uh, time zone aware, uh, date

1:47

time. And then you've got a local one,

1:49

which ensures that the time zone is

1:51

local time. And then a UTC. So

1:54

there are some other, other, uh,

1:56

solutions out there that deal with you.

1:58

Just assume UTC.

1:59

plus zero, but that's often

2:02

not convenient. And I guess one of the things they

2:04

had was they wanted to be able to have daytime

2:07

items as objects and then be able to

2:09

sort them, but have them keep, like

2:11

maintain what time zone they were created in

2:13

and stuff, which is kind of an interesting

2:16

thing. So they've got, it

2:19

looks just like working with time zones. So it looks

2:22

pretty easy to work with if you've ever

2:24

worked with time zones. They do have some other cool

2:26

features like statically

2:28

type checkable and pedantic

2:30

integration, which is kind of neat. Anyway,

2:34

they've got also an article about

2:37

why they created it. Time

2:39

flies when you're having zones, nice. So

2:44

it's a pretty interesting discussion going through

2:46

why they chose the solution

2:48

they did of creating their own and

2:51

everything. And being able to use it with MyPy

2:53

also is kind of cool. Yeah,

2:56

neat time zone. Shout out to Arrow and Pendulum

2:58

as well, or some of the other well-known ones, yeah. Yeah,

3:01

even a daytime UTC they found, but

3:03

it's UTC zero. And

3:06

then they even talked about why they, like how they

3:08

designed it and why. So their first

3:10

thing was just create a completely new type,

3:13

but then they came up

3:15

with some problems with that. So they came

3:17

up with sub-classing. So then these

3:20

new types are types of

3:22

daytime also, so you can use other things to

3:24

go with them. So I think that's a cool solution. I'm

3:27

not usually a fan of sub-classing, but

3:29

I think the sub-classing in this case makes a

3:31

lot of sense. Anyway, what

3:34

you got for us? That looks good.

3:36

I think it sounds so easy to be working

3:38

with time, but it's always so tricky.

3:41

Yeah, I have something, keep you with

3:43

the same color scheme here, a

3:46

new release for Wagtail. And I don't

3:48

believe we've talked about Wagtail before. It's

3:51

possible. I did

3:53

get a chance to use our search today, and

3:56

just reminded how nicely

3:58

that goes, I guess. at least

4:00

mention it somewhere. But Wagtail is a

4:04

CMS, the leading open source Python

4:06

CMS built

4:09

on Django, but you don't necessarily have to know

4:11

Django. It's kind of like WordPress in

4:13

the sense that you could just go through

4:15

the setup steps and run WordPress

4:17

and not even worry about the fact it's written

4:20

in PHP. So Wagtail

4:22

is a little bit like that, but just pip install

4:24

Wagtail to get going. And it's

4:26

got some really cool features. I haven't really explored

4:29

it too much, but it's got this really cool visual designer

4:31

for people to build out web pages and

4:33

stuff. Isn't that cool? So you can like hit

4:35

a little plus, you get like a nice

4:38

wizzy wig. I'm gonna insert a heading or insert

4:40

a table or like a image

4:42

gallery with these images. I have a cool

4:45

tree structure so you can organize your

4:47

content and because it's a Django, you can

4:49

extend it doing Django things, which

4:52

is pretty sweet and has a bunch

4:54

of, you can make little snippets that you can use inside

4:56

your pages, so that's pretty neat. It

4:59

even has a library for managing your images.

5:01

So pretty cool stuff. And the

5:04

news item today is an article by

5:06

Megan Voss. Come over to the dark side

5:09

with Wagtail 5. So Wagtail 5.0

5:11

is a new release here with

5:14

a bunch of cool things. So

5:16

Dark Mode, if you want your website, which

5:18

is backed by Wagtail, to have Dark

5:20

Mode. Well, Dark Mode is a thing. It's

5:22

pretty excellent. I'm a big fan of Dark

5:25

Mode. It has SVG

5:27

image support in addition, scalable

5:29

vector graphics in addition to just JPGs

5:31

and stuff. It has an accessibility,

5:33

an enhanced accessibility checker. That's pretty

5:35

cool. Like if you're creating content and it's hard for

5:38

people who have to use screen readers or something, it can

5:40

tell you that you're not doing that. Like missing

5:43

paragraphs is heading. Misusing

5:45

paragraphs is headings. Use proper tags.

5:47

Incorrect heading hierarchy. Avoid skipping levels.

5:50

Oh wow. And things like that, right? But

5:52

yeah, certainly my handwritten stuff

5:55

that's only, you know, if I remember that that's

5:57

how it's supposed to go, right? So pretty sweet.

5:59

What's wrong with that? five h1s on one page. No,

6:02

I know. I really have a

6:04

lot to say here, so it's all h1s. It

6:07

also has, what is the, if you want

6:09

to delete, like

6:11

say you have an image or something, it's

6:13

in your gallery and you're like, ah, not gonna use this

6:15

after all, hit delete. It keeps track

6:18

of if it's used in any other pages, so you don't

6:20

accidentally delete something that's

6:22

being used in some part of the site you didn't know about

6:24

that someone else created. That's pretty awesome. More

6:27

snippets, more validation, and

6:29

they threw away a bunch of old code so

6:31

they can work better, which may

6:33

even have a blog post on addressing

6:36

technical debt, so a few breaking changes,

6:38

not too many, but check it out. Anyway,

6:40

Wagtail looks pretty awesome, right? I think I may

6:42

have talked about it a long time ago, but anyway, not

6:45

the 5.0 release, because that's quite recent. Yeah,

6:48

I think it's pretty cool that that's

6:50

there, and I do have plans

6:52

to play with it at some point, but I've had plans to

6:54

play with it for a while. Indeed.

6:57

Kim, out in the audience says, I know several

6:59

one-person technical businesses that really like Wagtail

7:02

for their sites, easy to use for technical,

7:04

competent users, but doesn't require much of their

7:06

time to maintain. Yeah, that seems great. Yeah, nice.

7:10

Over to you. Well, I

7:13

guess I go away from Python a little bit,

7:16

but we use it all the time, so I

7:18

wanna talk about Git. So

7:21

I don't think I use any other revision

7:24

control systems anymore other than

7:26

Git. No CVS? No, no

7:28

WinCVS, any of that good stuff? Perforce?

7:32

Subversion. Actually, I touch

7:34

on subversion once in a while, but- I

7:36

still have kind of good feeling towards subversion. The

7:38

other ones make me a little queasy. Anyway,

7:42

the thing that I often wanna

7:44

know is just like the stuff that happened

7:46

recently on a file or something,

7:48

or just on a Git repository. RCS,

7:51

Mike Felder, oh, FieldDeebler, sorry.

7:54

Nice. RCS, wow. Takes

7:57

me back. One

8:00

of the things is the get log. So looking

8:02

at what's happened recently, but the get

8:05

log output is not something

8:07

I like to do. Actually using get

8:09

log is one of the reasons why I often pop

8:12

up like a visual

8:14

tool to look at my get repository

8:17

because it's gross. But I

8:19

forgot, and I knew that you could

8:21

customize it, but I kind of forgot how to,

8:24

so I haven't been. But now I

8:26

have because of this article. So there's an article

8:29

called get log customization from Justin

8:31

Joyce. And so the default is

8:33

something like that, which we're showing. It's got

8:36

a really long hash number and

8:38

a bunch of information, but it's

8:40

hard to find the information you need. One

8:42

of the things that

8:45

Justin points out is that you

8:47

can do just something really easy by

8:49

passing in one line. They just the

8:52

flag, the two

8:54

dashes and one line, all one word

8:56

will make it pretty nice,

8:59

actually. It just does a short

9:01

hash and you can kind of see what's going on a little

9:04

bit better. But it goes a lot further.

9:07

And I'm going to hop down to this really cool customization.

9:09

One of the things is using

9:11

graph. Graph is great. Dash

9:14

graph so that you can see kind

9:16

of it does like kind of a visual representation

9:19

of the different one

9:21

of those. The branches and

9:23

the merges. That's it. I forget

9:25

branches and branch or fork. And

9:27

ASCII art for the win there. Yeah. ASCII

9:30

art. But then you can do like color and stuff.

9:32

So there's

9:35

the graph does color also if you

9:37

have that on your on everything. But it

9:40

talks about how it also talks

9:42

about how the one line is actually

9:44

a like a combination

9:47

of pretty one line and abbreviate

9:49

commit, which is kind of cool. And

9:51

then what I really love

9:53

is this the thing that he like comes up with at

9:56

the end. So the I didn't know that

9:58

you could put aliases in the. get config

10:00

file. So or at least I did

10:03

once and I forgot about it. But this is

10:05

a pretty cool long alias. He's

10:07

got LG instead of log. So

10:10

save a character of typing right there. But

10:12

it defaults to, so it's an alias

10:14

for log with a graph with 10.

10:17

So default to the last 10 commits. And

10:20

then this long format thing that

10:22

is kind of ugly to look at, but what you

10:25

get is he talks about what it all is,

10:27

but what you get is, um, uh,

10:30

the brand, the graph, but you also

10:32

get, uh, somebody's name highlighted

10:35

of who did it. And then also how

10:37

long ago. So was it 19 hours ago or 24 hours

10:39

ago or two days, three days, uh,

10:43

really cool. Uh, exactly what I

10:45

need usually when I'm looking at a get log.

10:47

So I love it. This actually inspires

10:49

me to maybe play with this as well. And I

10:51

usually use source tree. I really like

10:53

source tree, but you know, sometimes you're

10:56

already in the terminal and just, you know,

10:58

yeah, and so all I did it, what I did is I just

11:00

like opened up my home directory, get

11:02

config and added this alias. And now

11:05

I just use get LG. Um, and

11:07

then I can forget all of this. The other

11:10

ones, I need things. I'm like, well, what if it says

11:12

by default, you can put the default, whatever you

11:14

want for this alias, but like 10 lines,

11:17

what if I want to see like 20 lines or 30 lines? Well,

11:19

if you say get LG, even though it

11:21

has the dash 10 built into it and pass

11:24

in a like a dash 20 or dash 30, that

11:26

the second one overrides it. Um, so

11:29

that's clever works just fine.

11:31

So nice. So,

11:34

so thank you Justin Joyce for writing this

11:36

up. Nice job, Justin. That's

11:38

pretty awesome. All right. I saw that

11:40

David Lord was the one listed

11:42

there in the example. Yeah. Let's

11:45

keep, let's keep going. That theme. Okay. So over

11:47

to, historically from

11:49

the flask side of things. So you

11:52

want to talk about flask. I want to talk about Jinja.

11:55

So Jinja is the templating

11:57

language that is the default for so many

12:00

frameworks. It's not best, I don't

12:02

think. Come on, Chameleon. So

12:05

much better. But it doesn't

12:07

matter. If everyone's using Jinja,

12:09

that's what people are using, right? It's

12:11

built into all the frameworks. You've got to jump through hoops to

12:14

use Chameleon with, say,

12:16

fast API. I created a library to

12:18

do that kind of stuff. But this is about Jinja. Its origins

12:21

come from Flask, originally created by

12:24

Armin Roaniker, no longer the

12:26

maintainer. David Lord and folks over

12:28

at Palettes is. But this new

12:30

project I want to give a shout out to does come

12:32

from Armin and it's called Mini

12:35

Jinja. Like Jinja,

12:37

but smaller. So Mini

12:39

Jinja is a powerful but minimal dependency

12:42

template engine for Rust that's compatible

12:45

with Jinja and Jinja too. So if you've got

12:47

a Rust project and you want to have those

12:49

templates, you could use this and you'd be like, okay,

12:51

I might go well. Python podcast. So

12:53

yeah, Rust is popular, but it's

12:56

comparable if you've got a Python app. It's

12:59

basically not 100% identical, but

13:01

pretty similar, right? The

13:03

other thing though, that's kind of interesting is

13:05

it does works with Python

13:08

through a project called Mini

13:10

Jinja-Py. And that

13:13

allows you to use the Rust

13:15

runtime back template engine on

13:19

whatever thing it is that you're working with. All right,

13:21

Flask, fast API, whatever. Right.

13:24

So you might want to use this instead

13:26

when the full set of Jinja 2 features

13:28

is not required and you want to have the same

13:30

experience across Python or Rust. There's

13:33

places where you can get a slightly better

13:35

performance sometimes than Jinja.

13:37

It was created using maturing

13:40

and Py03, which is pretty

13:42

cool, like the Rust Python bindings

13:45

and yeah, it just shows you how to set up and whatnot.

13:48

So if you're out there doing the web things,

13:51

maybe have a quick look at

13:53

Mini Jinja if somehow that's relevant

13:55

to you. Continuing the Rustification

13:57

of Python. Indeed. You know, it's

13:59

been a around for a long time, over 30 years. So

14:02

surely some rust is starting to develop. I

14:04

wouldn't have expected to come on so quickly all

14:06

at once like that, but there you go. Yeah,

14:09

nice. That's it for all of our items,

14:11

I would say. Okay. And I've

14:14

got some extras, but I know you do too,

14:16

so maybe you go first. Okay, well, I was

14:18

up, we

14:20

were just talking at the beginning of this before

14:24

we went on air, that I was having some audio

14:26

trouble last night, but I was getting the

14:28

PyTest Primary Power course ready and

14:31

launched last night. So chapter six, got

14:33

done recording that yesterday morning and

14:36

in the evening finished editing the audio. So

14:39

the first course in a series, PyTest

14:42

Primary Power, and to sell, so what

14:44

does it cover? It covers test functions, fixtures,

14:47

built-in fixtures, parameterization markers,

14:49

and it's really the set of things I think

14:51

that you have to know to be able to be

14:53

using PyTest effectively. You could just

14:56

take this first course and I think run with it for

14:58

quite a long time. So to celebrate

15:00

getting it done and back to school, I know

15:02

everybody's with kids, their

15:05

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

15:10

out of the house, you actually have time and

15:12

energy to study things again. That's

15:14

my house anyway. Yeah, yeah. So

15:17

I'm offering a deal for it, so 49 bucks for

15:21

the first course and if you wanna do the bundle,

15:24

$99, and the bundle's kinda fun because

15:26

I've already had some, we've got a lot of channels

15:29

to get feedback. I had some feedback last

15:31

night and this morning saying, hey, I'm

15:33

trying this on Python 3.8 and

15:36

it doesn't work, but it does now. So

15:38

this morning I did the, it

15:41

was like the From Future import annotations I

15:43

had to do to make the annotations

15:46

from 3.10 be compatible to Python,

15:49

way back to Python 3.7. So I

15:51

tested it on 3.7 this morning. So everything

15:53

should be working. So anyway, pretty

15:56

excited about that. Excellent, yeah, congratulations,

15:58

that's a big step. If you see something. like this,

16:00

you're in the right place. So thanks. How

16:03

about you? The testing code logo,

16:05

enroll in the course for 49 bucks. Awesome. Keeping

16:08

with the course theme a little bit, I have three

16:12

new courses coming out at Talk Python Training.

16:15

We have a new HTMX

16:17

plus Django course, which is going to be excellent.

16:19

A new language based course

16:22

without more detail on that. And one

16:24

or two data science courses coming in

16:27

quite soon. And since it's a bunch of a bunch

16:29

of things, all of them not quite released

16:32

yet. Just point people at Talk Python

16:35

Training. Talk Python dot com slash get notified.

16:38

And there, if you're not already in the mailing list, put your

16:40

name and email in here and

16:43

you'll get to hear about them when or keep us

16:45

in the podcast. I'm sure I'll talk about it then as well. I

16:48

just want to give a shout out to Cloudflare

16:50

Turnstile. I've been going through and classifying

16:53

trucks, cars, crosswalks,

16:57

stoplights. Holy moly. What

16:59

a dreadful, unnecessary

17:02

thing. So way back in three

17:04

or four on October

17:09

2022, I talked about Turnstile, which is a privacy

17:11

friendly, user friendly,

17:14

privacy, preserving, preserving, alternative

17:16

to reCAPTCHA and all those things. And

17:19

it just sits down here. And while we're waiting,

17:21

you know how like sometimes if you are slow, filling

17:23

out a form, it'll say your

17:26

selection of taxis has expired and you

17:28

got to do it again. This one

17:30

automatically I saw it while I was waiting for you to talk

17:34

about your new course and bundle. That thing

17:36

just did a little flicker and regenerated its

17:38

validation with no user input just in

17:41

the background. Tell you. So

17:43

how does it know you're not a robot? You know, it

17:45

runs some JavaScript and it also

17:47

I think, you know,

17:49

I don't remember all the details. It runs through

17:51

a bunch of other heuristics that like they

17:54

know from, I think from your IP

17:56

address and talking to, because, you know, Cloudflare

17:59

like runs. something like 25% of

18:01

the internet. So they can tell if you're going to a bunch

18:03

of different sites and things. And it kind of uses

18:05

that background information. I think, I think

18:08

anyway, I have not even had to

18:10

find a taxi to be able to submit that, but

18:12

it's a, it's made it so that you

18:15

don't have a bunch of automated stuff coming in. Exactly.

18:17

People used to be hammering on it too. And all

18:20

sorts of bad stuff. That's not good. So,

18:24

uh, yeah, I had to add it for like the login

18:26

page, um, and for

18:28

the, the registration page, a bunch

18:30

of bots were signing up. I'm like, I don't understand why they're

18:32

signing up because it's a free account and you

18:35

don't really get anything for free. So I couldn't understand

18:37

why they're all, but hundreds of them were signing

18:39

up. Okay. I got to do something. And then, uh,

18:41

this is a, an improvement over reCAPTCHA. All

18:44

right. PiBay. PiBay is coming

18:46

up October 8th. I will

18:49

be there speaking about Python

18:51

type hints and how you can

18:54

superpower your apps, something like five

18:56

amazing ways and tools you can use with your apps.

18:58

I believe is what my topic is roughly

19:01

supposed to be, but I will be there. And,

19:03

uh, people can, they happen to be

19:06

in the San Francisco arrow area. I want to

19:08

be there. They can check it out. They give me a

19:10

coupon as a friend of speaker.

19:13

If you use that friend of speaker, no spaces, you

19:15

get 20% off regular tickets. So that's

19:17

always fun. Nice. Yeah. Always a fun

19:19

trip or road trip down to San Francisco.

19:22

And let's see following up on your

19:24

doc strings. We've got some really nice follow up here,

19:26

Brian. Rhett Turnbull says, uh, with

19:29

regard to the doc strings article, Brian

19:31

covered, uh, last episode, the

19:33

Google format allows for

19:36

a raises section. Remember

19:38

I said, Oh, it'd be awesome if you could say actually what

19:40

errors could happen. Yeah. That's really cool. And

19:42

Rhett uses Google doc string format for projects

19:45

type hints, descriptive variable names, MP

19:47

docs and MK docs strings get

19:50

pretty doctor free and VS code will pull

19:52

doc strings so you can see them in the editor and co-pilot

19:54

practically writes the doc streams for you, which

19:57

is excellent. And, uh,

19:59

one second. attribution, John Hagan sent

20:02

over something same pretty similar. Remember

20:04

we said, look, you don't necessarily need to include the type

20:07

in the docstring. If there's a type hint, and

20:10

sure enough, you don't have to. Oh, cool. You

20:12

can just give it a description, which is cool. It also

20:14

points out the syntax for how you use the

20:16

raises. So you say raises, and you give it

20:18

a list of exception types,

20:20

and then the description of when the scenario

20:23

is when that might happen. So for example, raises, invalid

20:26

factorial error if n is less

20:28

than zero. This is the time that that happens.

20:31

Oh, cool. Isn't that cool? Yeah. Yeah. And

20:33

finally, John also points out that

20:35

PyCharm has the integration

20:37

for Google docstrings

20:40

somewhere in here. Yeah. For

20:43

Google doc format and how to set that up. So

20:46

it'll automatically autocomplete

20:48

and render Google docstrings when you say,

20:51

give me the quick help, control Q, and

20:53

it'll like just pop that up as a rendered sort

20:55

of thing there. So a lot of follow up on the

20:57

docstrings. Awesome. Cool. Yeah.

21:00

And that's all I got for my extras. How about

21:02

a joke? What do you think? Yeah. Ready? I've

21:05

got your joke, and then I want to do a dad joke

21:07

also after that. Awesome. So this

21:09

one is a lesson in optimization. Careful

21:12

what you measure. Careful what you ask for, right? So

21:15

there's this picture of two tennis

21:17

ball containers. You know those tubes that are vacuum

21:19

sealed? Yeah. One of them is not

21:22

at all optimized. It stores only

21:24

three tennis balls. The

21:26

one to the right says, look, if

21:28

you cut the tennis balls in half, you can store

21:31

six tennis balls in this container.

21:34

Way more efficient use. Yeah.

21:36

Yeah. I mean, your tennis game might suck, but... That's

21:40

awesome. Yeah. Yeah. So there

21:42

you have it. Yeah. Okay. So

21:44

over to you to close it out. I've got a joke

21:46

that I was reminded of the other day with... I

21:50

shared with my kid. It's a whole dad joke. So

21:53

have you seen birds fly in a bee formation

21:55

before? Sure. Have

21:57

you ever noticed that sometimes that one side is a lot

21:59

longer? longer than the other or it's longer than the other. Yeah.

22:02

Do you know why that is? There's more birds on that. It's

22:04

optimized. Amazing. Anyway,

22:08

it's terrible. I love it.

22:11

I love it. Perfect

22:13

dad joke. All right. Well, perfect episode

22:16

as well. Thanks for being here. Thank you.

22:19

Thanks everyone for listening. Yeah.

Rate

Join Podchaser to...

  • Rate podcasts and episodes
  • Follow podcasts and creators
  • Create podcast and episode lists
  • & much more

Episode Tags

Do you host or manage this podcast?
Claim and edit this page to your liking.
,

Unlock more with Podchaser Pro

  • Audience Insights
  • Contact Information
  • Demographics
  • Charts
  • Sponsor History
  • and More!
Pro Features