Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 373, recorded March 5th, 2024.
And I'm Brian Okken.
And I'm Michael Kennedy.
And you're just back from, where were you last week?
I was in the Philippines, hanging out in warm weather, meeting some new people, experiencing new places.
It was excellent.
Nice to have you back.
Yeah, thanks. Good to be back.
This episode is sponsored by Scout APM.
We'll hear more about them later.
If you want to connect with us or the show, we're on Fostadon.
You can go to mkennedy at Brian Okken or at pythonbytes at fostadon.org.
And if you're listening to us later, you can join us live if you want.
Go to pythonbytes.fm/live and join the audience there.
So, Michael, what do you got for us first?
Well, I have some super fun stuff.
This one is not purely a Python thing, but it sure is helpful for Python developers.
Brian, would you say that you use the terminal fair amount?
Yes.
In your world?
Yes.
As do I.
And like navigating the terminal is always a bit of a hassle.
I'm like, Michael, did you really need to have it that deep of a directory tree folder structure for this thing?
Because you're CD in this, CD in that.
Like, did you need to name the same?
So, like, tab complete doesn't really help you as much as you would want and so on.
So, I want to tell you about Zoxide.
So, Zoxide is like CD, you know, the command, one of the very first things you learn when you learn about terminals, command prompts, and so on.
But it's way better.
The oxide is because it's written in Rust.
So, that probably means it has VC funding or something.
No, I'm just kidding.
But it is backed by warp, which I've talked about before, which is also written in Rust and I believe does.
Anyway, the idea is that there's a little graphical animation.
So, the idea is once you install it into your terminal, and whatever terminal you're using, it pretty much supports that.
Okay.
Once you install it, it will start to remember all of your directory changes, at least if you use it.
And I'll tell you more about that in a second.
But if you use it to move around, like, imagine you've got a directory.
The example they're using on the screen here is something like, let's see, some long path slash foo.
You know, some slash long slash path slash foo, right?
Like a big directory structure.
You could just say CD foo, and it'll just take you into that structure.
Because it's like, all right, well, if the only directory structure I've ever seen that you actually cared to go into that involves the word foo,
is this one.
Cool.
You could say CD long, and it would take you just some slash long.
Once there's more than one, there's like a conflict, then you can do a couple of things.
You can hit space and then tab, and it'll pull up like a little autocomplete.
Or you can, instead of like the hotkey they show or the command they show is Z, you could Z for some of our folks.
You could type ZI for interactive, and it'll show you like a fuzzy completion search deal of all the history you've ever had.
You can go into kind of an interactive way to go and find the files or the paths that you've looked for before.
So isn't that cool?
It is cool.
I definitely need to check this out.
Yeah.
I've been using it for a few days, and I really like it.
So a lot of what you know about CD is the same as Z, so you can say Z dot dot.
You can say Z minus to go to the previous directory, not necessarily up one, but just wherever you were before.
Like I said, you do the ZI for the interactive or type a little bit and just space tab to pull up autocomplete.
And you can get it in a bunch of ways.
Like look at all these platforms.
Linux, macOS, Windows, BSD, even Android.
And on Mac, you can do a bunch of ways.
You can condo forge it.
You can ASDF it.
You can homebrew it.
All those.
And then look at all the different shells here.
Wow.
Yeah.
Even conch the Python-based one, but it's got the Z shell, which is what I'm doing these days.
And then if you want that interactive version, you need to install FZF, which is a command line fuzzy finder thing that you can do.
And then the thing that's interesting is like when I did this, there's no way, no way I'm going to remember to type Z.
I'm just going to type CD.
And then after a while, I'll be like, oh, I should have used Z, but it won't be in the history.
So let me just swap it out for Z, for CD.
You know, swap those.
And so what you can do when you install it, does it say on here?
Probably, maybe it does.
Oh, it's up under the configuration.
So in the shell configuration bit, you have to do this eval, zeoxide, init, ZSH.
But then you can also say --command, CMD, is some other character.
If you don't want to use Z, and if you say command is CD, then just CD becomes this thing instead.
And of course, if you don't like it, right, you just comment it out and it goes away.
Okay.
That's what I did.
That ends up showing up in one of your .files or something.
And then you can.
Yeah.
I put it in my ZSHRC.
Okay.
That file for me.
And just put that at the bottom.
You know, if I ever decide, you know what, I just want my CD back.
I could take that part out.
Or if I don't like this, I just comment that thing out.
It's pretty cool.
Yeah.
I was just thinking, I don't know if I want to type Z because that's with my pinky, whereas
CD's with my middle finger.
Then I'll probably map it to something else like E or C or something.
Yeah.
Or just CD.
Yeah.
I switch it to CD.
And then if you want to do the interactive, you do CDI.
But I think this is cool.
It's not going to change your life, but it's also...
Little extra things that make your life a little faster.
It's good.
I find it really interesting that on both Windows and Mac, Linux to some degree, but Windows
and Mac, even more, especially Mac, you open up the default terminal experience and it is
bad, bad.
It's like they want you to stay out of it.
You know what I mean?
Yeah.
So it opens up.
It's white, white background, which I don't know, for some reason, terminals, it just seems
wrong for that.
But then also it's like the wrong font.
The fonts are incredibly small.
There's not hardly anything installed to help you, right?
It's just so many levels of you can add on these little tools that just make it so much
nicer.
So anyway, I'm a big fan of this.
Before we move on, one question from the chat was, does it remember directories across terminal
sessions?
It does remember across terminal sessions.
I think it must keep a little hidden folder file or something like that.
I didn't pay attention.
But yeah, it's just you need to have interacted with it.
I'm pretty sure it does it across sessions.
Okay, cool.
Yeah, definitely check it out.
Yeah.
Speaking of command line interfaces, I'd like to talk about building them.
Oh, yeah.
So smart.
There's an article called from Raul.
I think smart CLIs with typer.
And I was like, just excited to see this because I love typer.
And I've been using both typer and arg parse a lot, actually.
When it, I guess for me, I use typer if I'm already importing other stuff.
But if it's a package or a project that doesn't have any external dependencies, then I'll try
to use arg parse because I don't want to pull in an external dependency just for typer sort
of thing.
However, but typer is really fun.
This is a cool article.
And what I was surprised by was there was a whole bunch of stuff I learned in this.
Even though I've been using it for years, there's some great things that I didn't know
about.
So there's a great article.
Check it out.
But the first thing I want to say is like right off the bat, it just talks about sort of a
comparison between an arg parse version and a typer version.
It's not hugely different, but it just talks about how typer, you don't have to like declare
your arguments.
You just have a function.
You can just have it, discover it.
You can just have a function like main and and typer figures out that all of your type
hinted arguments to that function are now arguments to your script, which is cool.
But I want to hop to the things that I didn't.
Maybe I knew about and forgot or just never knew about like how easy it is to do help.
So, well, help is actually a little easier in arg parse, but it's not that bad in typer.
You have to have to do a typer annotated thing with argument with help on it.
It's a little clunkier.
I guess just it's not that bad, but it's a lot different than the if you don't want to
help, you just have to.
It's a little bit more work.
Anyway, prompting for input.
I did not know you could do this.
So if you have like you like you would add help, you add a prompt instead.
If it's if it's left out, what happens is typer will prompt the user for it.
So like in the example, it gives a name and an age for this little example script.
If you forgot to put an age, it'll pop up and say, how old are you?
That's that's pretty cool that you can add a really cool.
Yeah, I really like that, actually.
I'm definitely going to have to try this because that's there's a lot of times where it's good
to have like some defaults, but also.
Yeah.
Speaking of defaults, you can also add an environmental variable so that if the default doesn't have
to be hard coded, but it could be an environmental variable that you set.
And then if you didn't if you didn't add the argument, it'll pull it from an environmental
variable.
So very cool there.
What else?
It talks about explicit apps versus is it is it kind of a different way to do it and to do
a couple ways to do our typer and explicit app one is one of the ways.
One of the neat things you get with that is multiple commands.
And so there's an example of doing multiple commands.
I love that feature of of of typer.
And then as a comparison, a similar sort of a thing with our parts would have been sub
commands.
So kind of a fun article.
And then I kind of got lost in the whole reusable command thing.
But yeah.
Yeah, this looks great.
Yeah.
I didn't know about the input one or the environment variable one.
These are both awesome.
Yeah.
Cool things.
If you're if you're making your own command line interfaces.
And I also appreciated the shout out to our parts, not like because that is the other
one.
Most people should consider either typer or arch parse, I think so.
For sure.
Andrew out there says that, yes, Z oxide does have a persistent database, as I thought.
And also asked whether typer supports the union operator, the pipe operator for types.
Not sure.
It said it didn't use to.
I'm not sure if it does.
I don't know.
I think you could run into issues.
Like if you said this is pipe int or pipe date time, like I could try to parse as a date
time, but then see the number as like a timestamp.
Right.
I can see.
I don't know.
I can see how it can be tricky.
So maybe it's by design.
I'm guessing not yet, but I guess just maybe based on the last time I tried it, because
one of the things is optional.
So you if one of the things I love about the bar for for for types is to be able to say int
or none as an optional thing.
But that's not how you do it with typer with typer.
You have to say option, like at least last time I tried it, you had to say optional int
equals none.
But actually, this is even yeah, optional makes it so it's like int or none.
So yeah, cool.
Cool.
Awesome.
What else is awesome, Michael?
Our sponsor.
Our sponsor is awesome.
Let's take a moment and thank them and tell you about them.
And then I'll get back to it.
Let me tell you real quick about Gout APM.
They're big supporters of Python Bytes.
So we appreciate that very much.
So if you are tired of spending hours trying to find the root cause of issues impacting your
performance, then you owe it to yourself to check out Scout APM.
They're a leading Python application performance monitoring tool, APM, that helps you identify
and solve performance abnormalities faster and easier.
Scout APM ties bottlenecks such as memory leaks, slow database queries, background jobs, and the
dreaded N plus one queries that you can end up if you do lazy loading in your ORM.
And then you say, oh, no, why is it so slow?
Why are you doing 200 database queries for what should be one?
So you can find out things like that.
And it links it back directly to source code.
So you can spend less time in the debugger and peeling logs and just finding the problems and
moving on.
And you'll love it because it's built for developers by developers.
It makes it easy to get set up.
Seriously, you can do it in less than four minutes.
So that's awesome.
And the best part is the pricing is straightforward.
You only pay for the data that you use with no hidden overage fees or per seat pricing.
And I just learned this, Brian.
They also have, they provide the pro version for free to all open source projects.
So if you're an open source maintainer and you want to have Scout APM for that project,
just shoot them a message or something on their pricing page about that.
So you can start your free trial and get instant insights today.
Visit pythonbytes.fm/scout.
The link is in your podcast player show notes as well.
And please use that link.
Don't just search for them because otherwise they don't think you came from us.
And then they'd stop supporting the show.
So please use our link pythonbytes.fm/scout.
Check them out.
It really supports the show.
Awesome.
Brian, have you looked into like buffer overflows and how all that kind of bad stuff happens?
It's the first time I learned about it.
It was just fascinating about how you could abuse computers.
Yeah.
Well, I'm in C++.
So a lot of the time.
So you basically create buffer overflow.
Yeah.
Like commonly.
Yeah.
Well, you know, C++ got the like the not just the print F, but like the safe print Fs and
other things like there was additional like checking ones to help prevent that.
Right.
But our very own NSA, who knows something about buffer overflows, I suppose, recommended
something pretty interesting.
It says this was actually a shout out to Samuel Colvin, who put this on Twitter.
I don't know.
I think Twitter needs to decide what it is.
Is it X or is it Twitter?
I mean, I know they use the word X and the symbol X, but what's the domain?
It's not X.com.
It's Twitter.com.
Come on.
So what are you?
All right.
Back to the topic.
Exeter.
I think X Twitter is the best we can do.
Anyway, he pointed out something with some interesting commentary here said the U.S.
government, specifically the NSA, looking to say, hey, maybe we should have it harder to
break into our systems.
The government explicitly recommends six memory safe languages.
Okay.
And then he also creates a bit of a juxtaposition here.
C# created by Microsoft.
And there's usually like one or two people behind this.
For example, the C# was Anders Hausberg, who also did TypeScript.
Go created by Google.
Java created by Sun.
Bought by Oracle.
Rust created Borm by Mozilla.
Swift by Apple.
And Python created by one genius on his own Christmas holiday.
Python is an extraordinary demonstration of the impact one person and the group that they
build can have on the world.
Which I think brings together two interesting ideas here, right?
Like that Python is officially one of the memory safe languages recommended that we should be
using by the NSA.
And then just the effect that Guido has had.
Yeah.
It's pretty wild.
I think it's interesting that I didn't really realize that Rust was memory safe.
Yeah.
That's interesting too, isn't it?
It's, it's, I think that's part of its magic, right?
How it's kind of a low level systems language, but it's way more memory safe as well with its
ownership and all that.
And then, oh my gosh, this really took off.
It must be why I saw it.
781,000 views.
But then if you look, if you look at the comments, the comments, I can't see it because I'm not
logged in, but there are many, many comments and the commentary is varied and interesting.
Down there, let me just tell you.
But yeah, I think this is interesting.
Like just one more reason to use Python or, you know, other memory safe languages as well.
But for example, in the comments, people pulling out, well, Rust was created by one person
while they were at Mozilla, but I, you know, he gets, it's maybe a little bit different
to say, you know, you were funded by this big tech company to create this thing.
And, you know, you did it.
Yeah.
Well, I mean, you have to, we have to, we're not really, I mean, I don't think Samuel's
intending to diss all the other languages.
There's, there's definitely.
No, he was more props to, to get, but if you look at all the comments, it just, it does
what you would expect a post like this to do as people like get their, you know, their,
their baby, not quite love.
Highly notable in its absence is JavaScript here.
Hmm.
Yeah.
Interesting.
Yep.
All right.
Well, we'll leave it there.
People can check it out, but that's.
Yeah.
So we'll also have to, I haven't looked at the recommendation, the NSA recommendation either.
So I want to check that out as well.
Yeah.
The NSA says use Python.
Use Python.
Yes.
I mean, you know, and we all listen to the NSA.
I mean, in this case too, though.
Yeah.
I thought it was the other way around.
Didn't the NSA listen to us?
No, I know.
Oh yeah.
Right.
Okay.
So I'm going to go back to the, the command line world for a moment and talk about textual.
So we've talked about texture before, well, McGuigan's, child.
So, with came from rich than textual, but, textual is over at textual.textualize.io.
So that's, a great place to look for, demonstrations and stuff.
So if you go there, there's some, some cool demos of what other people are doing with it
and some other pocket projects.
These are great.
Wow.
The Dolphy looks cool.
Anyway.
Um, so what I wanted to cover was that it does have its own tutorials.
Um, so if you go, go to the main page, you can go on tutorials and there's a, there's a
great, tutorial for how to use it.
There's a little timer tutorial.
It's nice.
Um, but maybe, maybe the way that they're teaching there just doesn't fit you.
So I was really glad to see that, Mike Driscoll over at mouse versus Python has some
textual tutorials that he's started.
And, what caught my attention was the creating a modal dialogue for your two E's with tech in
textual, but he's got like four different, blog posts around tutorials around textual
right now.
So, Mike's done some great work teaching people before.
So I wanted to shout out to Mike for this.
The modal dialogue is kind of fun.
goes through a little, fairly simple example, but the code's really just not complicated
to follow along with.
So, really kind of fun, talking about how to do a mold, modal dialogue, because
that's something.
Why would, are you sure you want to quit?
I love it.
Are you sure you want to quit?
But there's other things like, are you sure you want to delete your entire repository?
Um, and then we were, we recommend a where clause in your delete statement against the
database.
Yeah.
So anyway, good job, Mike, for, for jumping on this and helping to teach textual.
So cool.
Yeah, that's really cool.
Textuals.
Very, very interesting.
So cool.
So, all right.
Well, those are our topics.
Um, do you have any extras for us?
I have just a couple of extras.
Uh, I'd like to go through here.
So one, you know, in Grok, we've talked about in Grok before, if you need to let people access
services, typically HTTP, but it could honestly be anything on your system.
You could run in Grok.
It's super cool.
I'll use it, pay for it.
You know?
So like I'm working on a web app and I want somebody to be able to actually interact with
it, but I'm behind a firewall somewhere else.
So you can just run in Grok, get a SS, SSL backed URL.
That's kind of some random thing that people will go to.
So that's the CLI and all that, but they've released a little while ago, in December,
they released a in Grok Python SDK.
So if you want to write apps that basically temporarily spin up ways for people to get into
systems, like maybe you're on a Raspberry Pi or you're on some IOT thing and it's locked
away somewhere, but you need for it to be able to.
People to get to it under certain circumstances or whatever.
Right.
Then here you go.
Write some code and you plug into all that infrastructure.
It's pretty cool.
That is pretty handy.
Yeah.
Yep.
I don't have a particular use case for it, but cause I just use in Grok directly, but
I'm a big fan of in Grok and I think, you know, I'm sure there's going to be some interesting
things.
You can even do a Unix sockets like Unix.sock thing, which is pretty wild.
So it gets, it gets quite, quite advanced.
All right.
What else?
Let's see.
I recently, we talked, you brought up Djangonauts a while ago.
And so I recently had, Sarah Boyce and Tushar Gupta from the Django knot program on
talk Python.
That was, I think released last week, recorded a while ago, but released last week.
And so just want to give a shout out to that since we brought it up first on the show.
Nice.
Cool.
Yeah.
Then Sarah was very excited to hear you mention it when you brought it up.
It said on the show, this show on our, on talk Python.
She mentioned that she was excited to hear it here.
So that's cool.
Also, I had a re interesting experience with my phone brain.
I was looking at my phone going, I'm not sure I really liked the color anymore.
And I've had it for a little while.
Maybe I'll get a new phone.
And then like, what is wrong with you?
Oh, it's, it's an iPhone 13.
So I've had it for a while, but you're just going to put a black case on it anyway.
Maybe you just get a different case.
And you know, it kind of doesn't hold its charge long.
So maybe just get a new battery for it.
It's like, depending on the one you got, 69 bucks, 89 bucks for a new battery, instead
of like a thousand dollars for a new phone, $5 for a new case, 90 bucks for a new battery
dropped by the Apple store.
They'll switch it.
I just want to encourage people like, Hey, you might be able to just up, you know, improve
your phone or you don't give it a different color without going over the top.
Yeah.
What do I got?
I got an eight plus that I'm using.
It still works fine.
It just changes the battery every couple of years.
Yeah, exactly.
And it's, it seems pretty trustworthy to do it at Apple, right?
They use the same battery or better.
They might not have the same old battery.
Sorry, you got to get a better one.
Okay.
Take it.
Nice.
Cool.
Anyway, that's, that's my public service announcement for people.
out there applies to Android as well.
You can get a new case for Android as well.
Okay.
Well, I have a couple extras.
One of them is a public service thing, but the first one is just a shout out to a Hinnick's
new video.
We talked about uv a couple of weeks ago, I think, or last week.
I can't remember.
And there's a video called is uv the future of Python packaging.
And it's, it's like 20 minutes, 17 minutes, but it's, it's a really kind of a nice look at
the background of really what's going on here.
Uh, the speed ups might not seem the speed.
Everything's fast.
Faster is great.
Right.
But there's more to it than that.
And, kind of about some of the future that they might be putting together after this
is, is important.
Um, so interesting, interesting discussion.
I encourage people to check it out.
The other public service service announcement that I wanted to say was I use Venmo occasionally,
mostly to send money to and from my daughter.
Um, but, but I didn't notice, and I don't want to show off too much, but that's
Venmo, you know?
Um, but I was surprised when I looked at my old transactions and found that, the,
uh, there's a feed feature where you can, where everybody that's connected to you or even not
connected to you can see everything that you've spent money on.
Um, and I'm like, what the heck is this for?
Not this money, but like why the little message to the person and all sorts of stuff.
I don't think you can see them out, but you see that somebody paid somebody else and then
you can click on the other person and follow their feed and follow other people.
And this doesn't make sense for finances.
So, I would encourage everybody to go into your settings and just turn that to private.
Nobody needs to see that.
Um, I don't know why there's a social feature for a money sharing app.
What?
It's horrible.
It's weird.
It's horrible.
I ended up using Venmo as well because my kids are like, dad, I'm going to Venmo you.
How about PayPal?
Venmo.
I'm like, all right.
But yeah, it's, it drives me nuts that I could see people that I was even, you know,
friends with like 15 years ago.
I still see what they're buying and who they shared lunch with.
It's just like that.
It doesn't belong in this space.
I just don't think.
So yeah.
Turn, turn the feed off.
Turn the feed off.
And also I don't think it shouldn't be on by default.
And also people don't know about it.
So other people, you know, that use Venmo, let them know that their feed's public.
So yeah.
Anyway.
Cool.
Well, that was kind of serious, but do we have something funny?
Oh, this is very serious too.
No jokes.
All right.
So here's a developer and a project manager speaking.
The developer starts out and says, I can ship this feature that you want in four weeks because
listen, I need to write maintainable code.
We can't just have like this tech debt piling up and all this junk, right?
Like this is a professional organization.
The PM says, what if we delegate maintenance to someone else?
Oh, I can release that in three days.
Exactly.
No test, Brian.
We don't need tests.
Come on.
Yeah.
Well, yeah.
So optional.
That's someone else's problem.
Just kidding.
Well, is done when all the defects are done?
No.
You don't report that to the other person.
The API is frozen.
Yeah.
Anyway.
Exactly.
Well, three days.
I can hack that in three days.
Yeah.
No, no problem.
We got it.
You got it covered.
Yeah.
My favorite is when somebody asks like one person on the team, how long to take this?
Can you get this to get it done?
And, and like one stage says like a week.
So they promise a customer a week and there's like so many other people that need to work on it.
Yes.
Oh yeah.
Oh, did you want documentation?
Oh, you want that?
You want that written up as well.
Oh, I see.
Oh, a user interface for that also.
Oh, that's going to be.
Nobody pointed that out.
So yeah.
Tests or none.
Yeah.
Anyway.
Wait, we got to close it out with a comment from Alvaro.
Test pipe none.
Test or none in the typing system.
Yeah.
Optional.
Tests are optional.
Yeah.
Anyway.
Again, thanks for the wonderful episode, Michael.
We'll talk to you next week.