Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 357, recorded October 17th, and I am Brian Okken.
And I am Michael Kennedy.
And our show is sponsored by us.
Check out Talk Python Training, of course.
There's wonderful courses from Michael and other people, including myself.
And Patreon supporters, of course.
We love Patreon supporters.
We haven't really talked to him much lately, sending out emails.
I should do that more.
And lastly, the complete pytest course.
Please check it out if you want to learn pytest the fastest way possible.
And you can connect with us on Mastodon, on Mastodon, on Fosstodon, both of those.
And Michael's at M. Kennedy.
I'm at Brian Okken.
And the show is at Python Bytes.
And you can also listen live if you head over to pythonbytes.fm.
And you can watch it when we live stream, as we are right now.
Absolutely.
So, Michael, let's kick it off with something hot.
Let's kick it off.
I want to talk about a couple of, well, something I've learned from Glyph when I was at PyBay.
Was that last weekend?
Two weekends?
Last weekend, I guess.
Glyph gave a really cool talk.
Some of the talks are starting to show up on YouTube, but his talk is not there yet.
Or I would link to it.
And it was something along the lines of like, how to program your computer with Python, which sounds silly because we're all pretty good Python programmers.
Like you should think, okay, well, I could do that.
But this was about, how do I automate stuff?
How do I plug into things?
Like how can I automate keynote to extract show notes out to put into another document or PowerPoint or, you know, things along those lines.
And one of the things that he both created and talked about was this thing called Quick Mac Hotkey.
Because you might want to have your Python not have a UI you're interacting with, but just be chilling in the background.
And if you had a certain hotkey, it does the thing, right?
Yeah.
So this Quick Mac Hotkey does that.
And basically it's super simple to use.
It's just a set of minimal Python bindings for macOS framework APIs using, what does it use for it to pull this off?
Look through here.
Oh yeah.
Py OBJC, I believe is what it's using.
So you just super easy to write some code.
You want to have a function that's called when a keystroke is down.
You just give it the decorator quick hotkey and you say the virtual key is the X.
The modifier is command control option.
So just hit all three of those plus X, you know, something that's most likely not going to interfere with some other behavior.
And then boom, off it goes.
And look how simple that code is.
Isn't that nice?
Yeah.
That's pretty cool.
Although I don't know if I can find my command control and hotkey at the same time.
But cool.
Yeah.
I use a Windows keyboard, unfortunately, because there's no ergonomic Mac keyboards.
Like, you know, apparently Apple hates people and they want them to have RSI for the rest of their life.
But doesn't they only make these?
Does the window key map to the command key?
Yeah.
The window keys is just the command key.
Yeah.
Okay.
So it's nothing too fancy.
So there's not a lot of depth.
And we got to dive into this other than how cool is it if you want to just add hotkeys here?
Yeah.
So off you go.
Okay.
So when you install it, does it just run all the time or something?
I think whenever your app is running.
Okay.
Like, so you can see the last line of this example.
It says app helper dot run event loop.
Okay.
So that's just like set there in the background and just wait for events.
For example, it's this quick hotkey callback when somebody presses that.
So one of those, though, could be exit.
You know, and just, you know, I don't know how you exit the event loop.
Either raise an exception or just just exit or who knows.
There's got to be a way to get out of there.
Reboot your computer.
Exactly.
It's like Vim.
You're just in there.
Nice.
All right.
Over to you.
Well, I'm going to talk about command lines applications a little bit because Simon Wilson
had things I've learned about building CLI tools in Python.
And I really kind of like all the stuff he covered.
I really like them.
I mean, this isn't a super in-depth like how to write CLI tools, but some of the things like
just high level when you're writing command line applications, it's good to be rather consistent
with other command line applications to make it easy to use because it's going to be used
by people that like CLIs, right?
So a couple of options things here.
Be consistent with the terms.
Well, you have to kind of understand the terms, but there's commands, there's arguments, there's
options and flags, and sometimes flags are options.
Yeah.
Anyway.
So commands that have our, he's using CLI applications.
So the, he actually talks about CLI and also using a cookie cutter template that he lists
at click app on Simon W on GitHub, but the, or yeah, cookie cutter template to build these,
which is cool.
I like typer, which is built on top of CLI.
So anyway, but these are, these are still good, good advice, like make sure that your
options, what, you know, what options are and then make sure you have like a short character.
So if you have --port also include like a dash P as a short version, because people
are used to that.
There's a mostly just a lot of description around making sure your flags and options and stuff
are consistent.
And I actually think people ought to get used to writing more CLI apps because especially
for utilities for yourself and for a team, they're great because you'll use it all the
time and it's, it's, you get used to it.
It's easier than building a GUI application.
So consistency is everything.
Try to be consistent with it.
One of the great things, the great advice here.
So is he pay attention to your help message.
So, a lot of CLI tools like typer and click kind of build a help for you so that it
prints out like the options and stuff that you can, you can list, which is great, but you
have to go in and add things like, put examples.
So example uses of like the entire application or the entire option and how to use it.
Um, this is extremely helpful and I really appreciate it even just for myself so that,
um, like six months from now I can remember how to use it, things like that.
So include options in the help.
And then the other thing is, the lastly, Oh, examples, examples in help.
And, there's a couple other things.
Oh, include the output of your help in your online documentation.
And there's ways to automate that.
But I think that's great to just list it because I'm looking for it when I'm looking at the,
like at the bottom of the read me or something.
Um, the lastly, is if you have a CLI that's being used by other people, make sure that you
version it appropriately because, because it is an API.
A command line interface is, can be used by other programs.
So treat it as an API, even if the other user is somebody's fingers.
Um, because if things change, people should know about it.
So anyway, good, good application or a good article about building command line applications.
And then his, cool cookie cutter template for click apps.
It's nice.
Excellent.
Yeah.
Nice work, Simon.
A couple of pieces of real time followup here.
One audience is on point today.
So Kim out there says rich, rich click is also fantastic if you use click.
And I definitely agree on that.
So it's like click, but all the help messages and stuff are in color using, you know, rich
and like little info boxes and stuff.
And then Rhett who, Rhett, who was on talk Python to talk about programming, Mac apps, macOS apps
highlights that, you know, this quick hockey thing sounds like a good opportunity for a rumps menu bar app.
So rumps is awesome.
I was actually thinking of adding this hockey thing exactly for one of my rumps menu bar apps,
which is just an unfair level of easy for building a Mac app that just runs in your menu bar.
Oh, cool.
Yeah.
We've talked about that, but it's been a while.
It has been a while, but you've got it for me.
I've got to go up and find it and like, make it do the thing.
I'm like, you know what?
A hot key.
Oh yeah.
Here we go.
Now it's on now.
It's going to the next level.
So yeah.
Yeah.
Super cool.
All right.
That's not what I want to talk about, but some good real time followup.
What I want to talk about is warp.
And this is also an item from PI bay indirectly.
I ran into Elvis who works there.
And have you heard of warp Brian?
No.
Well, I mean warp speed.
Yes, I know.
Okay.
Got to resist the star Wars references.
Um, it's, it's super cool.
So what terminal do you use?
Like when you go to use the built-in Mac one, do you use iterm two or what's your story?
Well, I use the built-in Mac one, on Mac and then on windows, I use, the, what?
The windows terminal.
Well, that was a good one.
No, the, the get bash, get for windows bash comes with bash.
So I use that.
Okay.
Yeah.
You should check out the windows terminal and then plug the get for bash into it.
You get like, it behaves better and you can pick from like nine different shells and like
things that run inside the windows terminal.
Anyway, windows terminal is awesome, but we don't have windows terminal on Mac, which is
just fine.
Cause we have iterm and other things, but I want to tell you about warp because warp is
a new terminal.
Uh, it's got quite a bit of energy behind it and it's, it's awesome.
Um, so I think there's 30 people working on this project if I remember correctly, but there's,
there's a good number of people that are working on building this new terminal based on rust.
And it even is, programmed in metal shaders.
Metals are like the open GL direct X Mac equivalent for making it super, super fast.
But basically like there's a bunch of shortcomings that always drove me crazy about the terminal
and a lot of things that are pretty nice here.
So it's a free thing for individuals.
If you're a company, you got to pay for it if you want to company features.
Uh, but it's, it's worth checking out.
So for example, if you write something, Brian, like I write, some multi-line command and
you're like, Oh no, I forgot the quote at the beginning.
You know, how do you fix it in I term left arrow, left arrow, left arrow, left arrow, left
arrow.
Like even home doesn't work, you know, left arrow, left arrow, left arrow.
You wait and get back there and you type the quote, right arrow, right arrow to get the focus
back, like clicking where you want to be doesn't work.
Right.
For example.
Well, he's used Vim key bindings and just go there with Vim.
Do you have Vim key bindings in the mat at the standard terminal?
Yes.
Everywhere.
Yeah.
Okay.
All right.
But awesome.
Well, so this one, like basically all the, stuff you type at the bottom or wherever you're
typing is like a full on editor, which also has Vim key bindings.
Yay.
Okay.
No, go ahead.
Okay.
Uh, you can turn them on if you want, but you can basically click in there and edit pieces.
Like you can double click.
It'll select a word.
You start typing or places that super cool.
Um, it has like a kind of a new way to like keep your input focused in one area, which is
really nice.
So instead of it just being at the bottom of the screen, you can have it like always at the
top or always at the bottom.
Um, one of the things that's cool is like it treats the output of every command as,
a solid as one thing.
So if I do like an LS and there's like 50 lines and I tail a catalog or something, then there's
like a thousand lines.
And then if you want to go back, you can actually just go back by selecting each block of that.
So go back a thousand lines, go back 50 lines, do a search.
You can search just that 50 line section from that one command, even though your terminal is
full of junk.
Super, super cool.
Uh, it does tons of autocomplete, which is super neat.
Um, let's see one thing else.
Um, you can, if you do some kind of command, you're just talking about like Simon asking
ChatGPT for what does like a command mean.
So if you said like LS dash one, what does the one mean?
You know, you hover over the one, it'll like pop up a little documentation for what dash
one means.
Oh, that's cool.
Yeah.
Uh, also as AI built in, if you want, I haven't used that very much, but you could like say
hash, how do I, you know, write this kind of loop in bash or whatever.
And it'll, it'll print it out for you, but I don't use that one too much.
But anyway, super, super cool.
Um, a lot of interesting things.
It has the control R history, kind of like, like McFly, which I've talked a lot
about how cool McFly is.
So even the single try for a few weeks, really enjoying it so far.
Cool.
Love to try.
So people can check that out and yeah, pretty neat.
Kim says, we've come a long way from a few years ago when windows terminal and awesome
is in the same sentence.
Um, it's, I, yeah, I thought it was a joke also.
I didn't, I can't believe that you said that, but no windows terminal is it's, I don't
want to be on Wikipedia, but it is definitely, definitely nice.
So I'm not on my windows machine and I'm not sharing my terminal anyway, but let's see if
I can get it to show, hockey.
So like, and it doesn't really show it great, but you can click on this, like you set what
the default shell is that you want it to do, but you can click this.
It'll be like the bash shell, the, power shell, whatever that thing's playing music.
I can't take it.
But yeah, anyway, the windows, yeah.
Check out windows terminal.
It's actually good.
And Kim is right.
We've come a long ways, but yeah.
Okay.
All right.
Mm-hmm.
You convinced me, I think.
So let's try it.
Give it a, give it a try.
Give it a try.
All right.
What's your final thing?
People should check out warp.
It's, it's pretty neat.
I will.
Yeah.
Oh, hold on.
One more important thing here.
Mac only for the moment for people, but they're working on Linux and windows.
So you can like sign up to get notified if you're not a Mac person.
So just that caveat for now.
Um, I, did you, I three, Python 3.7 end of life.
And I didn't even notice.
What?
So.
That was a good one.
That was one of the good ones.
You can trust that one.
So 3.7 end of life was in June and June 27th.
Uh, no, that was the first release.
End of, no, end of life also.
End of life.
6.27.
23.
Interesting.
But why did I not notice it?
I didn't notice it because everybody's like three, like you said, 3.7 was one of the good
ones.
We got, we have data classes in there.
Uh, f-strings came in 3.6 and they got improved in 3.7.
And then they, they got improved in 3.10 again.
Um, and all sorts of stuff, but, but it is something to pay attention to, that
I had noticed the first notice today.
Um, I was looking at the, VS Code announcement for the new, what was this?
Python for Visual Studio Code, October, 2020 release mentions, that, the 3.7 support
is still, it's still probably works, but they're deprecating 3.7 in support.
So just to be aware, I was also surprised if it didn't work because what was removed
in 3.8 that was in 3.7, like syntax wise, not functional wise.
I, I can't think of anything.
Uh, yeah.
So I, so there's a couple of projects or several projects that I'm supporting where I support
down to 3.7.
Um, I dropped 3.6 a while ago.
Uh, but one of the things that catches me a lot, the, the, the remaining thing that catches
me, is, is annotations and specific.
I want to cover like if you really want to still support 3.7, or didn't know that it was this
easy, at least for the code I write.
The main thing is, is I like to use union types.
So, like to use this or type for unions.
And this came in in 3.10.
However, it, I, I can't find this documented anywhere, but to get it to work down to 3.7,
you can do, from futures from future import annotations.
And we've been used to using the from future for various things for a while, but it looks
like, like 3.7 might be the end of needing from future for a while.
I don't know.
Maybe they'll come up with something else that they're backboarding, but it doesn't look like
there's anything else right now, up to 3.12 that you need to go back down.
It's just, just, just annotations so far.
So, and I guess I want to show a little bit of an example for the annotations.
So, data for data classes, data classes are awesome because you can type the, the variable
that you're in using.
And, and then I often like to have it be none by default, which, so a string, it's going
to be a string or it's none.
So the, or none is easy just to do the, or none.
And I know you can do optional, but this is just visually more pleasing to me.
Um, and to get that to work down to 3.7, it's, yeah, it's just the from future important
annotations and it'll work all the way down to 3.7.
So it's just what I wanted to mention.
Um, and, I think that it's also good to be aware, I guess that, that, 3.7 is end
of life because some of the things you depend on might start dropping support for 3.7.
It's fair game at this point.
So, I mean, open source projects, they're a fair game to drop support for, everything
below 3.12 if they want to.
No one's, no one signed a contract with anyone here.
They can do what they want.
Yeah.
But it's, it's good to be aware of.
So.
It certainly is.
That's a cool graph you got there too.
Yeah.
Is that in the, is that in the show notes?
Yeah.
It's from devguide.python.org, with the versions.
Um, yeah.
Uh, Christian Lederman says, walrus was introduced in 3.8.
I don't know if you can do a from future import walrus.
I don't think so, but it's too bad.
If you do, you have to do an emoji, not the actual word walrus, but you got to put the
emoji of a walrus and then it'll work.
Well, I'm waiting for like emoji operators.
Uh, so that'd be fun to have.
Yeah.
Have to put not just can put, but you have to put emojis in your code.
So what happens when the cat raises its paw against an integer?
Oh, let me tell you, that one's really awesome.
Yeah.
Uh, yeah.
Some of those conversations like, Christian was saying that I think we're like, or I was
saying, you know, what is in three, seven, that's not in three, eight.
And those are all true.
All those things like there are new things, but if you wrote three, seven code and then
ran it against three, eight, it should still validate in my pie.
It should still work in Python, right?
There's no thing that was in three, seven that because my pie is not supporting it, it'll say,
well, that used to work and it doesn't work anymore because Python is pretty awesome and
stable like that.
There might have been, there was one point, I think it was in three, nine though, where
like the asyncio co-routine decorator was removed that caused all sorts of drama for me because
some library I was using didn't use the word async.
They just used the decorators, but even that a decorator should still validate in my pie with
that context.
Right.
So, yeah, I guess I want to, I'll, maybe I'll revisit my opinion of, supporting three,
eight or three, seven because, so we, we, we can use the wall.
Wallruss operator in three, eight, but Henry Schreiner also noticed that notes that,
uh, the, the equal for f-strings so that you can say, like X equal and it'll print the
X equal.
That's super handy.
Um, yeah, it's good for debugging.
Yeah.
And just having, having that stuff in your, in your code, like that'd be great.
So.
Yeah.
And these things are super small and subtle, like the wallruss operator.
I take, I took the website down with the wallruss operator once I said, I told that story
before.
Yeah.
Like not even the main website, just, it was in a little utility, but it got parsed
by the route finding thing and killed it.
All right.
Well, that's it for items, huh?
Yeah, it is.
Awesome.
Extras.
Uh, I got a couple since I got my screen up.
Um, just one of the examples I showed was from a new plugin that I just released, called
pytest Paramscope.
and this allows you to, for parameterized fixtures or for parameterized tests to have
a startup, a startup that goes, a setup that happens before all the parameters and a teardown
that happens at the end.
It's still, the API is up, there's a warning here because there's the, the API might change
with respect to teardown, working on yield, yield functions for that.
Um, I also, I was going to cover this as a full thing.
Oh yeah.
This is just sort of how you use it.
You get like a setup and teardown.
Oh no, this is, this is how I want to do it.
This is the change that I might do of adding yield.
So anyway, Simon Wilson, wrote a article called, stop defining people.
No, not Simon Wilson.
Sorry, Josh Simmons.
Uh, sorry, Josh, wrote an article called, stop defining people by what they
are not.
Um, and he was referring to non-code contributors and I kind of agree.
So I wanted to highlight this article.
This is, this is great.
Just basically saying all contributions are awesome and trying to, and elevating code
contributor contributors above non-code contributors is just not right.
So don't do that.
Um, also it's just referring, I mean, if somebody only writes, just mostly helps with your
test code, you don't have to call them.
I mean, you can say somebody that's contributing test code.
You don't have to say, oh, that's non-code.
Well, that's, that's still code.
But anyway, you know what I mean?
Um, people helping with documentation is great help.
People helping with writing tutorials is great help.
Everything is good.
So anyway, sometimes it's more important to have a good example so people can get started
quickly.
Oh yeah.
And like enjoy the project rather than like one more feature, you know?
Yeah.
And also things like, cleaning, triaging issues and answering questions and keeping,
you know, making sure that all the issues are closed when their things get fixed and all
that sort of stuff is, is it's tons of work.
So it's great help.
So yeah, absolutely.
Do you have any extras?
I got a couple quick ones here.
So open AI has released the beta version of their Python SDK.
It's pretty exciting.
So if you don't want to implement your own raw HTTP JSON parsing and hope that you got everything
right, you can just go there, start calling the functions that they write for you.
And it should be going nicely.
So it's still in beta, but people can check that out.
That's pretty awesome.
I think, was it here?
I can't remember somewhere.
No, it wasn't here.
Maybe it was on the linked article.
There was somewhere where there's a bunch of people whinging, like, why can't people just
call HTTP?
They're so lazy.
They want a library for it.
Like, you know what?
Maybe like let somebody else handle the evolution of that API.
You just call a stable Python set of functions and not worry about that.
Wouldn't call that lazy.
I would call that PyPI and call it awesome.
Anyway, so people are into open AI.
What do you need Python for?
Just call the raw C API.
Exactly.
Can I just do this with like a bunch of bash scripts and some curl?
Let's go.
All right.
So, sad news here is ChatGPT.
Oh, no.
Stack Overflow.
Probably because partly of ChatGPT.
Get that in order right there.
Stack Overflow is laying off 28% of their staff.
It's kind of surprising, huh?
Yeah.
Which turns out to be 100 to 200 people.
Like a lot of people.
Not like they had four people and they laid one of them off.
But it was really important.
What exactly would you say you do here?
No.
I didn't know that Stack Overflow had so many people working for them, though.
I know.
It was founded just by Joel Spolsky and Coding Horror Guy, whose name I don't remember.
Anyway.
But yeah, it's growing to be super, super big.
And I don't know, I always sometimes wonder, like, do you really need a thousand people to run that website?
I mean, maybe, but maybe you just don't.
Anyway, that's a whole different discussion.
But so there's some interesting conversation saying maybe this is because of ChatGPT and Google Copilot and all these other things.
Like, instead of going to Stack Overflow to go, how do I connect this type of thing to that type of database?
You can just ask your coding assistant or your chat buddy and you'll get a great example.
Oftentimes more specific, right?
Like, yeah, but I'm using this version.
Oh, well, if it's that version, you've got to pass this argument too.
Right.
Thanks.
Got it.
You know?
So this is pretty interesting.
Kind of odd or weird, like six months ago, Stack Overflow wrote a blog post that said, what's different about these layoffs in the tech industry?
Not us.
We're fine.
Everyone else.
And then, you know, six months later, you know, go back and read your own article, sadly.
So that's an interesting thing to be aware of, I guess.
Yeah.
Yuri Silovanov just pointed out or posted on the XT that UVloop18 is here with Python 2nd.
Python 3.12 support.
So I was trying to use 3.12 on a couple of the Talk Python things and the websites are like, nope.
UV loop, no.
AIO HTTP, definitely not going to work on Python 3.12, which is, I think AIO HTTP still doesn't work.
And sadly, some rummy dependency that I have is like using that library, which itself is not being upgraded to 3.12, at least as of like a few days ago.
So this gets me halfway there, the two things that wouldn't install.
One more to go.
Hanging in there for AIO HTTP.
Come on now.
Yeah.
Good news nonetheless.
Thanks, Yuri, for doing that.
Oh, and thanks, Kim, for reminding us that it was Jeff Atwood.
Yes, of course it was.
Thank you, Kim.
That's the guy that went by Coding Horror.
That's what happens when you have too popular of a nickname that you've given yourself, like Coding Horror.
Yeah.
In your blog.
Yeah.
Plus that logo or icon that he's got.
I can just see it in my head.
Yeah, too.
I can't.
Like the hair on fire.
Yeah.
Developer picture.
Yep.
Yeah.
All right.
Those are all my extras that I got for now.
Yeah.
Ready for a joke?
I am.
We might even have two jokes, but we'll see about that.
Yeah, I've got one I wanted to share also.
All right.
So this one comes from Command Line Magic, but was pointed out to us by Lizzie.
I said, I love it.
Hey, I'm Kennedy.
Maybe for the show.
And the Command Line Magic says, I've always read that global variables are bad.
So this is the Star Trek thing.
And can I make it bigger?
Yes.
The Star Trek thing shows, I can't remember this character's name, this woman scientist on a shuttle.
This is all from Star Trek.
And they're like going right through the near the edge of the sun to do some studying.
And she wants to be real careful to make sure that, you know, this ship doesn't melt.
So she says, computer, notify me if temperatures get too hot.
Beep, beep.
Please define hot, says the computer.
Let's say 1.9 million Kelvin.
Okay.
Fair.
Later, Captain Picard is at the like the little food making thing, you know, that materializes food.
It says, tea, Earl Grey, hot.
It just melts.
It just like, yeah, sets it at 1.9 million Kelvin in his captain's quarters.
Yeah, that's awesome.
Isn't that good?
Yeah, I like it.
Yeah.
A little too hot.
Somebody should test this.
Yeah, a little too hot.
Maybe that tea was real hot.
Yeah.
All right.
What's your joke?
So my daughter shared this with me and I just like, I haven't stopped giggling about
it.
So did you, have you, you've been to the Oregon Zoo, right?
Yes.
Yeah.
Did you, do you know there's a new exhibit there?
Ah, no.
It's just a baguette in a cage.
Oh.
It's bred in captivity.
Oh my gosh.
Bred in captivity.
Yeah.
That's hard to do.
You know, a lot of times you try, but it just doesn't happen, does it?
I guess they pulled it off.
Yeah.
Awesome.
So.
This bad, bad dad joke.
Those are very bad dad jokes.
But I was just thinking about going to the zoo.
I haven't been there since maybe a year.
I was thinking about taking my daughter back there.
So.
What's weird is we, we almost always go to zoo lights.
So.
Yeah.
But I, so I see a lot of animals, but they're all in, they're all in lights instead of actual,
the actual animals.
Exactly.
We need to go.
Yeah.
Just put them on the wall and have them flashing for Christmas.
That's right.
Yeah.
I actually, I really appreciate.
During COVID, they like started doing the drive-through zoo lights and they still do it like partway.
So you can do drive through for a couple of days or something.
And then they switched.
Okay.
The walking.
I like driving through.
It's nice.
So.
Yeah.
It was nice.
Definitely nice.
All right.
Well, we're coming up on the end of the year.
So we'll have to get a report on the zoo lights.
Yeah.
All right.
And the bread and captivity bread.
Bread.
Bye.
All right.