- Podcasts
- Python Bytes
- #357 Python 3.7 EOLed, We Hadn't Noticed
About this episodeTopics covered in this episode: QuickMacHotKey Things I’ve learned about building CLI tools in Python Warp Terminal ( referral code )…
- QuickMacHotKey
- Things I’ve learned about building CLI tools in Python
- Warp Terminal ( referral code )
- Python 3.7 EOLed, but I hadn’t noticed
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#357 Python 3.7 EOLed, We Hadn't Noticed
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.
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.
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. Yeah. That's pretty cool. Although I don't know if I can find my command control and hotkey at the same time.
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?
Nice. All right. Over to you. Well, I'm going to talk about command lines applications a little bit because Simon Willison 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 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. 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. 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. 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.
Yes, I know. Okay. Got to resist the star Wars references. 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 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. it's got quite a bit of energy behind it and it's, it's awesome. 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. 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.
Okay. Okay. No, go ahead. Okay. 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. 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. 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.
it does tons of autocomplete, which is super neat. let's see one thing else. 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.
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.
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.
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. I, did you, I three, Python 3.7 end of life.
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. f-strings came in 3.6 and they got improved in 3.7. And then they, they got improved in 3.10 again. and all sorts of stuff, but, but it is something to pay attention to, that I had noticed the first notice today.
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 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 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 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. 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.
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. It certainly is. That's a cool graph you got there too. Yeah. Yeah. Is that in the, is that in the show notes? Yeah. It's from devguide.python.org, with the versions.
yeah. 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.
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. 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 mypy 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 mypy 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 equal for f-strings so that you can say, like X equal and it'll print the X equal.
That's super handy. 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. I got a couple since I got my screen up. 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 API might change with respect to teardown, working on yield, yield functions for that.
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 Willison, wrote a article called, stop defining people.
No, not Simon Willison. Sorry, Josh Simmons. sorry, Josh, wrote an article called, stop defining people by what they are not. 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.
But anyway, you know what I mean? 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?
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 OpenAI.
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.
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. aiohttp, definitely not going to work on Python 3.12, which is, I think aiohttp still doesn't work.
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.
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.
