Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds.
This is episode 379 recorded April 16th and I am Brian Okken.
And I'm Michael Kennedy.
This week we are sponsored by us, Talk Python training courses and also the pytest course
and our Patreon supporters. We love everybody that supports us. We really appreciate it.
And if you'd like to connect with us, we're all on Fostadon, on Mastodon. So it's at mkennedy,
at Brian Okken and at Python Bytes. And I wanted to shout out to myself, I guess, and Michael for
we're doing a newsletter now. So if you head over to pythonbytes.fm and join the friends of the show
list, we will send you an email with all of the tidbits. So if you happen to miss an episode,
you can catch up on all the links that we share. So Michael, why don't you kick us off with our first
topic? Let's get started, huh? So I want to talk about an article by Stephanie Molin. She put together
this really nice article on something that I don't use very much, Git Precommit Hooks. Do you use Git
Precommit Hooks? Not, yes, on some projects. Yeah. And I just think there's a lot of possibility for
interesting things there. And, you know, I've considered it, but you don't want stuff that like
takes a long time to run there. So like how much value do you get? But nowadays with tools like
Ruff and others that run really quickly, it's basically you wouldn't even really notice it,
right? So it's not a lot of overhead. So maybe it's time to reconsider Git Precommit Hooks. And
she has a really nice walkthrough here. So I just kind of want to set out some of the motivation and
kind of call attention to this article. People can come check it out and set up Precommit Hooks for
themselves. So why do you care about these things? They give developers near instant feedback of code
locally. So not all, but some of the things that would run in continuous integration, like linting
checks and other types of checks run. And when you try to do a Git commit, and if it, for some reason,
there's a problem, right? Like it won't even let you commit. It'll say, no, it can't commit.
But you've got to fix the issue detected by the precommit hook. So it's kind of a gate
before stuff actually gets into broader source control world. And, you know, super valuable if
you're on a team, but also if you just want to make sure like, I kind of want to make sure I'm doing
this for myself for my own project, or I'm working alone at a company, and I still want to make sure
these things happen, then throw them in there. That's for you. Also, the continuous integration side of
thing is pretty excellent. So here, she's using a project, I believe by Anthony Sotili,
called precommit. And precommit is a Python project, but it's not only for Python things and Git and
source control. It just happens to run on Python, like some things run on C, some things run on Rust.
That's what runs on Python. So basically, as long as you can run Python things, you have an interpreter,
you can use precommit for whatever projects, you know, if you're a React native person, you could
use precommit for it, right? Yeah. So there's a nice example of showing how to set up a bunch of checks.
And it's super easy. Basically, you set up pre-commit-config-yaml file or .yaml. And then you
specify different things to run. And so you can say, I want to run the hooks forward, check the format for
the toml file, check the format for yaml files, make sure that every file ends with a blank line,
trim out all white, trailing white space, all those kinds. Those are all pretty simple and pretty nice,
right? Yes. Another one is throw in the rough precommit. And then I'll just say, run rough and run rough
format, which will fix up the things. And you can even pass arguments, do it through these precommit
hooks here, which is pretty cool. Yeah. So, you know, that's pretty much it. Once you set up your file, you just
have to run precommit install, which will, you know, download all the hooks that you've mentioned
that you want to run, all the checkers. And it'll actually create virtual environments for those and
install them in there. So the first time it's a little bit slow, but then the next time it's
plenty quick. And finally, if for some reason you're like, you know what, I know it keeps complaining,
but this time I just need it to commit because for whatever reason you can use down here,
find it, you can specify get commit --no verify. And that'll just say it's going in.
I don't care. It's going in if you need to kind of override it. So yeah, it's pretty straightforward,
really nice write up and people can check that out. If the idea appeals.
This is a great timing for this because I have used it in years past and there's times where I've
added like a whole bunch of stuff and it kind of slows down my process. But with the recent
rustification of a lot of a lot of our tools, like with rough and stuff, things are pretty zippy
now. So I don't think it'll slow down things that much. Yeah. I doubt you really even notice it,
you know? Yeah. For depending on what kind of tools you can do. When it fails, you'll notice.
Yeah. And I do like the, the shout out. There's a couple of things I love about this. I like the
shout out to the no verify because there's times where you're, you're just running off to vacation
and you have to commit your stuff no matter what, get that in there. Especially if it's on a,
like a brand developer branch or something. Yeah. That's a good point. If it's not on the main
branch, but you're like, you know what? I'm just going to put it here because I want to get it over
to my laptop and I'm leaving. Yeah. I need it saved. The other thing is running down some of the,
the rough settings. So I love, I love some of the configuration that she's included with,
with like how to configure rough. Cause rough, rough is awesome by default, but there's some cool
configuration you can do like setting, setting the quote style to single and stuff like that. So neat.
Very, very neat. Yeah. Stephanie's doing a bunch of cool stuff. So people should check out broadly
what she's up to, but this article is really nice. Yeah. Over to you, Ryan.
Well, I want to talk about something I talked about two years ago. So I was researching this
Diftastic and I'm like, I'm, I'm really loving this, this tool. I got to cover it. And I apparently
covered it two years ago, but I didn't, I haven't started using it until just recently. So
Diftastic is a tool and I, I think it's written in Rust. I'm not sure actually, but it's a super fast
Dift tool and it's, it does coloring, but there's a lot of stuff I love about it. The reasons why I'm
using it a lot. The colors are great, by the way. Awesome. Nice red, green, different colors.
But what I really love is that it's not, it's a Dift tool. That's not a line by line character by
character Dift. It's, it understands your syntax and it only changes things that really change. So if you
happen to add a new line in there or something, it's not going to show you that Dift. It's going to do
just real changes to your code, which is super helpful. I hate it when, when you have to like
turn off by default, it doesn't show you that. So I, I don't like to see if somebody, if I messed up
some spacing and somebody fixed that, that's not a real Dift. I don't need to see that. So having
syntax based is great. What I really love is what I've I'm going to highlight here is there's,
there's instructions. Oh, it tells you how to do it. And I can't remember where the link is,
but it, it, I'm going to show it right here. The, the, in the manual for a get tastic or Diftastic,
it shows you how to set this up for diff. So you can forget diff. So if you're using with get,
and you, you know, you want to just try it out, it shows you how to just set your get external diff,
and then you can try it out. What I really love is the real winner is doing a log. So
showing what you've done on the file recently is great with the get log. But if you do that with
the external diff of Diftastic, it's a fantastic experience, especially if you've got a large screen,
which I do right now. And it just makes things working with get so much easier. So definitely,
if you haven't tried Diftastic yet, try it and try, try the, so it shows you how to do it just
like one-offs for get, but it also, it shows you how to set up your get configs so that you can use it
all the time. So this is fantastic. Yeah. Very excellent. Are you starting to use it?
I'm using it every day now. It's just part of my workflow. So yeah.
Mike Fieler out in the audience says, Diftastic is indeed in Rust.
Yeah. It's, it's one of those, it's super fast. I love, I'm going to have to start learning Rust,
I guess, maybe, but, or, or just, I just love other people writing Rust for me so that I can,
I can write my Python even faster.
So it's like, it's kind of like when you use Jupyter notebooks, you don't have to learn TypeScript
and JavaScript and all those things. You can just use them and appreciate that someone else took one
for the team. Yeah. Yeah. Yeah. So awesome.
All right. Actually speaking exactly of that kind of stuff, the next thing I wanted to give a shout
out to here, the next topic is Quarto. Have you heard of Quarto? I don't believe so.
Yeah. So Quarto is pretty cool. It lives solidly in the, I want to publish stuff for various reasons,
maybe because I want a blog or a website or I want to write an ebook, or I just want to create a webpage
that shows my, my research or visualizations for my company or something like that. So basically it's
an open source scientific and technical publishing system based on Jupyter notebooks. And a lot of people
have been talking about this and recommending this lately. So I thought I'd give it a look. And so the
idea is you write in Jupyter notebooks with plain text or markdown or whatever you want to use.
And then you create the dynamic elements in Python, R, Julia, or observable. The role has always been an
adjective. I didn't know it was a noun, but okay. Yeah. I may have to check that out later, but
basically most relevant point is you write, you can write your stuff in Python and then you can create
production quality articles, dashboards, websites, blogs, and even EPUB books. So HTML, PDF, even Word,
EPUB and so on, which is pretty awesome. And then it's, it comes out of the Posit books. You can connect
it to Posit Connect if you want, but then you can write in hand doc markdown as well and get like
fancy math equation type things, you know, like integral from zero to infinity of that, to that. And
right. It looks proper, like you would see in calculus class, not weird ASCII representations to
it. So yeah, it looks, it looks pretty awesome. It has ability to like show or hide the code. You can
go to their website, you can see like there's a little example of here's a notebook and then here's
actually publication of it, which I don't know. I think it's, it's pretty cool. What do you think,
Brian? I think this is excellent. I definitely want to try this out. I've been itching to write more
long form and doing, doing something like this would be great. I think it would, especially if
you use Python to sort of express what you're working on or what you're doing, right? Yeah.
Super, super cool. Yeah. And pan doc, it's cool. They're using pan doc markdown because,
I mean, markdown is amazing, but the pan docs flavors of markdown, there's a bunch of cool
extensions. So that's pretty neat. Yeah. Also final thing you compare, apparently can embed things like
Jupyter widgets, HTML, widgets and others to let people sort of interact with the page as well,
which is also cool. Yeah. Neat. Yeah. All right. So this is your world. Check it out.
Definitely. Okay. Next, I want to talk about Constable. So this is a simple,
a simple debugging tool. Looks like it's fairly new. Look at that. So Constable.
Commit four days ago. If you find yourself aimlessly adding print statements while debugging
your code, this, this might be for you. So this is actually pretty neat. Oh, I like it.
See, throw like a, in the example that you throw a decorator at constable.trace, and then you can
throw in which variables you want to trace. And it just like, it shows you some cool output of like
what happens while you're, while you're running. And the, you can walk through and it does the
changes to your, which line changed your variable and what did it change it to and all that sort of
stuff. And it's kind of a. Each line that changes, right? It, it prints out like as the variables
change at any step, it'll say, here's what the new values are, which is cool, but it kind of describes
it, which is awesome. It'll say like this equation ran. So now it's a new, this statement ran. So
here's the value of this statement ran. So now here's the value. It's, it's really good.
Yeah. It's, it's fairly verbose, but, and with, with a lot of spacing in here, but I think that's
good is because you're, you're probably going to like throw it on just a couple of functions to
when you're debugging at the time and then pull it out.
Is it production?
Don't put it in production. I was wondering this too. So I forgot the name of the, the, the other tool
that was kind of like this. And Mike Felder or Fiedler says, I wonder how constable compares to
ice cream. And I think, I think I would take this as Mike is volunteering to do a write-up of comparing
constable and ice cream.
Definitely. Thanks, Mike.
Sounds. Thanks, Mike. Yeah. Let us know when that's written up and we'll take a look.
No. I, I think, I, I think probably a lot of this is just a probably feel like, how's it feel to you
if it fits your workflow or not? So this, this looks fun. So yeah, this looks very fun and both are new
to me. So it's, it's worth checking out. Okay. And if Mike doesn't want to do it, maybe I'll take a
look at comparing constable. Excellent. You could write it in quarter. Yeah. Yeah. So apparently Mike
didn't, didn't, was surprised at, you know, the volunteering. So anyway, so yeah, constable for
debugging print statements or it's easier than print statements. Yeah. Nice. Cool. I'm going to work
it into my, my world. I think it looks good. What do you got for us next? Extra, extra stuff. It's all,
I have only one extra thing. Oh, we're done with our topics already? I'm blue. So we are flies when you
have fun, you know, and you're cool. I flies. All right. So at least I'm done. I've got nothing
else. How's that? So two pieces of news here. They're all, they're both the same piece of news.
So Python 312.3 final is out, which comes with one, two, three, four security updates. They don't sound
like any sort of big deal. So, wouldn't like run, run and patch it now or anything, but there are
some things that sit under security. So that's always worth thinking about, but there's also quite a few
changes under built-in under library. I mean, just gauging by the scrolling, I would say there's probably 50 or 60
changes. That's a big change for a dot three dot tutor dot three. Yeah. Yeah. and why not?
Why not upgrade? So absolutely. And I would, just the other piece of news is that Python bytes and
all the other, other things are already running on a 312.3, just bump a number, kick off the, the Docker
update and boom. Yeah. Very nice to have that, that set up in place. Extras for you. just one that I
like was excited to cover, but then like, okay, so I'll just, I'll just talk about it. It's a couple
of, you appear to be offline. it's a couple weeks old, but pointers are going to be added
to the standard library with PEP for what? Yeah. What? apparently, Guida says, you know,
why the hell not? why not add pointers? This will induce, it, this will also introduce,
pointer literals size of operators and memory errors. actually I was perusing Reddit in
Python and noticed this and I'm like, what's going on. And then I noticed the date was 15
days ago. That would have been April fools. April 1st. So rough. I actually got off,
rough.
snagged on this. This is sort of funny though.
This is funny. I even has the C syntax, like ampersand to grab the pointer of a variable,
a star to dereference the pointer. It's all sorts of stuff.
Yeah. Malik.
Malik. Why not?
Why not?
New size of operator.
the irony is everything in Python as a pointer. You just can't directly address them. Right.
You can't, you can't work with them that way. no pass by rep. There's no pat like pass
reference, you know, the, the ampersand operator and C where like you could change the value of
the pointer, like within somewhere else. And so what, I love this example, spam equals star
of none. that's that will seg fault core dump. Good luck kiddo.
But this is good. I enjoy it. So yeah. All right.
People comments are like nice when I believed it. I believed it.
I believed it for a second except for, you know, anyway, but there is a infamous pointers.py.
So is that a real thing you can know bringing the hell of pointers to Python
from pointers and poor underscore.
That's funny. Anyway. all right. So,
this is, this is the ball, right? Involved. This is,
in-depth that wasn't just a Reddit post. It's got like a whole GitHub repo.
Yeah. Example. There's like a ton of code here. What are they doing?
Uh, this is awesome. Why does this exist? Anyway.
Liz out in the audience says I would have believed it too.
Uh, one of the features is seg faults.
always a good time. Always a good time. Yeah. All right. So, that was funny,
but do you have anything else funny for us?
I do. And it's very much in the same vein, although I don't think it's the same date.
I think it's just more random. So check this out.
Hennick from the Python community who we speak about often is here holding this award.
That is a Hugo, you know, Hugo, the, not the static site generator, but the,
the awards for,
It's like a sci-fi award or something.
Yeah. For best sci-fi science fiction. So here's the thing.
Very happy to accept a Hugo award for my science fiction short story.
The day Python packaging made everyone happy.
Good work, Hennick.
That is, that is excellent.
Someday.
And the science fiction is, is a good angle here. Right.
Because science fiction is the sort of stuff that's not real now,
but you can imagine maybe, but probably not.
At some point in the future, like the year 3000.
Well, I'll be fine.
Yeah. Well, I, well,
I don't believe anything until I get my hover skateboard.
I know.
So we're just going to be,
all it's going to be about is people crashing and falling over backwards on YouTube,
on the hover skateboard once we all get them.
Well, yeah.
Just like the ones with wheels now,
but now when you hover,
you'll even more tippy.
Still fine.
I'm trying to figure out how you turn on something that hovers.
I know.
But anyway,
all right.
All right.
Well, thanks.
This was fun.
A pretty quick episode,
but,
uh,
Oh,
Mike says,
uh,
hover skateboard uses pointers,
uh,
and seg faults.
Yeah.
Um,
so,
and then we can get like,
uh,
we can get Devin and,
uh,
AI to create,
um,
seg faults for us.
Yeah.
That'd be awesome.
Not my fault.
I didn't take down production.
Devin did.
I wonder if the segue is written in C.
I wonder if segways have seg faults.
I bet they do.
Yeah.
It would be fitting.
Uh,
all right.
Well,
uh,
thanks everybody for showing up.
If you want to,
um,
uh,
and if you're listening and you want to join the fun of talking with us while we're doing a podcast,
um,
head over to python by set FM and you can see what the schedule is for the next live episode.
Indeed.
Thanks,
Ryan.