- Podcasts
- Python Bytes
- #365 Inheritance, but not Inheritance!
About this episodeTopics covered in this episode: Hatch v1.8 svcs: A Flexible Service Locator for Python Steering Council 2024 Term Election Results Python…
- Hatch v1.8
- svcs: A Flexible Service Locator for Python
- Steering Council 2024 Term Election Results
- Python protocols. When to use them in your projects to abstract and decoupling
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#365 Inheritance, but not Inheritance!
Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 365. Wow. Recorded. It's like we've been doing it for a year. Yeah. Recorded December 19th, 2023. Yeah. And I'm Brian Okken. Hey, I'm Michael Kennedy. And yeah, if we did it, if somebody listened to one a day from now on, they would be behind because we'll be way ahead of 365 by the time they finish.
Still be awesome. Well, want to kick us off with something cool? Oh, before we kick it off. Yeah, go ahead. Let's say that this episode is sponsored by us. So please support us and other people. I'm going to talk about that a little bit later at the end of the show. But also check out all the courses that Talk Python Training.
Ooh. Nice. So hopefully that doesn't curse it, that something doesn't go wrong and it will crash. But 950 megabit down, which is fine, but 950 megabit up is glorious. We should speed up the playback speed when we release the MP3 so it sounds really fast. No, we're talking really fast because it's really uploading.
Yeah. No, let's talk about Hatch because Hatch is awesome. Ofek is the maintainer and creator of Hatch. And boy, oh boy, has he gone big on his latest release, 1.8.0. So Hatch is like Flit, is like PDM, is like pip, ENV, and many of these other poetry. Others, if I'm leaving your version of this out, I apologize.
But with version 1.8, this has gone in a bit of a different direction. You know, I had Ofek on the Python packaging panel. I think Steve Dower was there. Some other folks were there. Really interesting that there's this tension between should there be an app that manages Python environments with Python, or should there be a thing that manages the Python itself?
Right? Kind of like PyEMV, for example. Right? So Hatch has gone in that direction of now Hatch manages Python, not just Python projects. And there's this thing to solve this problem in the form of PyApp. So PyApp is even maybe more awesome. PyApp is a runtime installer for Python projects written in Rust.
And they can be, you ready for this? I'm so, so excited. Your Python app can be distributed as a standalone executable, a .exe or .app for users. What do you think, Brian? I'm very interested in finding out more. Now, this whole post is a little bit wordy. So let me jump into the omnivore version of it over here, which has a huge icon.
Right? So he came up with this thing called PyApp that will create installers for the different platforms. Claims it's trivial. It's probably never trivial, but possible. Possible would be awesome even. And so starting with this releases, not only are the binaries available for every platform, but there are installers as in like install wizards on Windows and a DMG type thing, I'm guessing, or a PKG on macOS.
That's awesome. If you have ever in the recent days tried to put something onto macOS or Windows, there's a whole nightmare of digitally signing around it, Brian. So you can't just get a binary and give it to somebody. The platforms will freak out. They won't let you open it. Like macOS will not let you open it unless you go into settings and say, allow me to run apps from untrusted developers.
And Windows gives you this big, scary dialogue and tries to not run it. So that's why this next part- It's not developers that you don't trust. It's developers that Apple doesn't trust. Yes, exactly. You may or may not trust them, but that's a different conversation. It's a fair feature, but it makes creating desktop distributable apps super painful.
So, because I have dealt with Apple and they are not lenient in any way, shape or form when it comes to stuff running on their platform. But so the installer for the macOS is signed using the certificate from the same account used to sign the official distributions of Python. So you won't get any security warnings or blocking.
Thank you, Ederbin, for helping out with that. And Hatch itself with any good system is self-updating. So you can hatch self-update. What else I want to point out? There's also a new Python, like hatch space Python command group that will allow you to manage things. So you can show what you have installed.
You can install different versions of Python, CPython and PyPy for those. It works with virtual environments. It has built in rough and Ruff format integrations. And traditionally, it's been somewhat slow to like activate and set up a virtual environment that's already previously been installed because it'll refresh and recheck that all of the dependencies are there and everything.
So now it does a hash of those. And so only if the dependency statement doesn't match the hash, right? Basically, so it'll pre-compute all that stuff. So now it should be basically instant. So also some minor breaking changes around build defaults. And the new app build target is what I've been raving about.
So, OFAC, you killed it. Can't believe it. It's awesome. Awesome. So Hatch has hashes? If you hash a hatch with hashling and, you know, like there's some kind of tongue twister in there we could do. I'm not doing it though. Gotta be. I'm excited about this. It's very cool. I definitely want to play with it.
Yeah. Yes, indeed. Over to you. All right. Well, I'm not sure how long this has been out, but Hinnick has been promoting a new project that he's got called services. He's got called services or SVCS, which is short for services and pronounced services. And it is a, I think it could be used for more than web stuff.
And it was for removing some of the web. Like your database and your cache and all sorts of stuff to an application. typically a web application. Typically a web application. But I think it could really be anything. But it's a flexible service locator. And one of the reasons why I haven't covered it yet on Python bytes.
I don't think I have is because I didn't quite understand what it was doing. And it took me a while to get my head around it. But it's pretty cool. And Hinnick apparently realizes that it is a bit difficult to get your head around what this is doing. So he just recently released a video describing this project.
So really great video describing services, what you can do with it, and also how to pronounce his name. He doesn't pronounce his last name, though. Apparently that's left for maybe episode two. But I love, I guess. Anyway, it's pretty cool. Actually, I'm pretty excited about it after watching it, watching the video.
Like, how do I do this in Starlet? Well, it's just a little different. Most of them, mostly they're similar, but little different ways to use it throughout the different applications. So it's pretty cool. He also mentions in the video that he took a really long time really talking about the terminology and the glossary of the documentation.
And actually, I really appreciate this of somebody saying, okay, this is generally what I think of is what the meanings for all of these words are. And it's a lot of these words are, they're overused in the English language to begin with. And even in talking about programming, web programming, but things like what is the service?
What is a resource? What is a dependency? Service layer. He goes through a whole bunch of different terms, what it means to him and probably to everybody else. But if you're unfamiliar with them, and even a decent discussion of dependency injection. So one of the things he talks about is that this is not really a dependency injection thing.
It's inversion of control, but it's a little different than service. Service locators are a little different than dependency injection. And I kind of appreciate that discussion. It's pretty cool. So anyway, kudos to Hinnick for doing this and for helping us pronounce his name. Yeah, this looks cool.
We have new leaders, Brian. We do. Yes. For the Python world, we have new leaders. And specifically, the steering council election results are in for next year. Okay. So for the 2024 term, we have Pablo Galindo Salgado. We've got Gregory Smith, Emily Morehouse, Barry Warsaw, and Thomas Werther's orders.
So very cool to see them all leading the way. There's a lot of familiar faces there. So that's. That's pretty cool. I don't expect a whole lot of different from the year before, but here's the results. You can actually see in PEP 8105, you see everybody who was potentially a candidate, how many votes they got by people who are disenfranchised.
Welcome and congrats. Awesome. Nice. That's a good set of names, too. Yeah. So. Yeah. All right. Indeed. Well, there probably is some protocol around the election results, right? No, you could model it with classes, or you could functionally model it, like, in an immutable way, but I don't know about a protocol.
Okay. We're just great at transitions on this podcast. The next, I want to talk about Python protocols. So there's an article from Carlos Vecina, I think, called Python protocols, defining a protocol and when to use it. And actually, this is something that I have, I've been meaning to play with for actually some years, and I haven't really done much with it yet.
So I really appreciate this article. He's talking about protocols are a feature of Python that were added in Python 3.8. So really anything maintainable right now can use protocols. But they're, and you kind of, they're, mentally, I think of them kind of like class inheritance or mix-ins or abstract-based classes.
And that's one of the things he talks about in this article is, is they are in that same similar space, but you use them a little different. And you might use them together with other forms too, like with mix-ins and abstract-based classes. So the article just goes through on how to define a protocol and really, and he's also discussed, also a decent tutorial on abstract-based classes and mix-ins as well, which is nice to kind of describe them all together.
But the protocol thing is just sort of, let me see if I can find an example. So you inherit, you have a class that's inherited from protocol and you give it, you kind of give it function definitions, but don't fill in the body. So that's kind of what a protocol is. And then other classes that use the protocol derive from that, you know, from that protocol, from like in his example, there's a class called, explainable, that something that has an explain function.
And then you can use anything that derives from that. So pretty cool. Yeah. Brian, let me jump in and just say one extra point. Brian, let me jump in and say, hey, what's awesome about this stuff is we've had duck typing like this. There's an assess fairness function that it has to call explain on the object passed in.
And duck typing said, well, if it takes that, if you can pass it in there and it will run when you call explain on it, it must fit. Right. But the typing tools don't check. So like PyCharm, for example, would just go, well, it's a whatever. So good luck with that. But once you do this protocol stuff, if you say the function takes an explainable and you have explainable as a protocol, you can pass stuff in and it doesn't even have to derive from or be related to that protocol in a base class.
That's pretty cool. No. Yeah. So clearly I haven't thoroughly read this article, but I do want to get into really getting my head around abstract based classes, mix ins and protocols and stuff. And I would say that though, because like your experiences in C++, mine also is in C++ and C# and all of those languages have these interface ideas.
So I'll, you know. Yeah. I'm actually sort of, I don't know, this is a tangent, but I've switched to, I was playing with like Bing as my primary search engine at work. I just, I don't know, a new computer, it just was there and I'm just going with it for a while. But everything I search is like, it gives me an AI generated answer first.
And I'm like, I don't know if I like that very much. Yeah, I know. I know. Anyway. Well, that's it for our main stuff. Do you have any extras? I could have almost made it an extra, extra, extra this time. So yeah, sure I do. First of all, I've been wanting to say this several times and I'm usually like looking at my screen and see what I want to share and stuff.
And I didn't have this anywhere. So I just pulled up Mastodon to remind me. There are tons of people interacting with us over on Mastodon and I've had some great conversations. And I want to, I'm sure you do too, Brian, want to follow people back. So there's, there's kind of a, at least for, I'll say these are Michael's Mastodon's conventions.
You, you could take them for what you want. I just made them up, but this is how I think about it. So people will follow me and I'm like, huh, did that person follow me? Cause they listened to the show and listened to Brian say, you should come join us and have a conversation. Hey, I'd like to follow that person.
But a lot of times they have no picture, no description, no web pages, no posts. You're like, yeah, maybe not next, you know? And so I'm just going to say, if you have a picture and a description, a description seems somewhat relevant. I will certainly follow you back. If you have posts, that's plus one.
If you have a verified webpage, which is easy, another plus one. And a lot of people have private accounts who follow me. I'm like, why are you in social media? If you want a private account, I don't understand what this is because your profile is public. Just your posts are private, but the platform has a way to have private posts.
I don't understand. So anyway, probably not going to get a lot of engagement. If you have a private account, just post private messages for things you don't want to see. So, and while I'm on the topic of Mastodon, I had a really nice and productive conversation with the PSF around my mask rant on PyCon.
So that was nice over there. Some people weren't nice as they sent me, like not necessarily nice responses, but the PSF did. And that was cool. That's nice. Yeah. All right. Next one. Oh, wait, before you move on. I just want to add my two cents on the picture. I also prefer to be able to see who it is, but also primarily if the picture is something that they're using on other stuff.
So like if a lot of people have a, their profile picture on their, like the profile picture on their blog and on their, and in their primarily a GitHub user and, and they have the same profile there, even if it's like a stylized something, but if it's the, if it's distinctive and the same everywhere, like glyph, for instance, has a, has a, a different thing for them.
I I'm okay with that, but most people I think go with their picture. I think it's the right answer. Yeah. When I say picture, I don't mean necessarily it has to be your picture. Just the fact that it's not the default icon. You've taken enough effort to put in something, even if it's just a picture of a triangle, I don't care.
You know? Yeah. All right. Paul is asking in the audience, what is your secret? Okay. Well, we'll do this. we, earlier on, we were talking about how Michael's got a faster internet now, so we should make it really fast speed. and then somebody commented, wagrants, wagrants, commented, I played it at one and a half times speed.
Then I got up to a live event. and all of a sudden Brian should sounded like he got drunk in one second. and so I said, Brian's secret is out. So nice. I'll just have another drink in my, Irish coffee. It's coffee. Trust me. Oh, all right. more extras. So, Dropbox spooks users with turning on new AI features that can almost automatically send your private documents to OpenAI.
Now you have to interact with part of the site for it to happen, but it doesn't say, Hey, necessarily, cause you does, you touch this. We're now sending your social security number away. but anyway, that's kind of. Well, I mean, yeah. So you can check that out on defaulted on if you're not subject to the GDPR, but defaulted to off if you are.
So, you know, plus one for GDPR there, I suppose. So mine was turned on. Okay. So you have to go check to make sure that they're not sharing all of your. Yes, exactly. And it's on by default for you, Brian. So you might want to check. The whole conversation it's on ours. The, the comment section of our second is like the top notch place for comments, I think.
So really good. Okay. Yeah. There's, it talks about how to go find it. So anyway, this like made me think, you know what? I should really be a little more. I have, I have like three terabytes of data and Dropbox. So I'm like, maybe I should be a little more specific and intentional about where I put my stuff.
Cause they can't decrypt it. Yeah. That, that solves a whole lot of problems. I don't, you care about the security, but it doesn't matter as much as if you're just exposing files or leaking stuff or whatever. Right. So I decided to go, I already have a, a paid Proton account. So all my private stuff, all my private documents and like my scans of things I want to save that might be sensitive.
They're going to Proton drive where I have 500 gigs and it's already paid for and encrypted. There's async thing you can install. That's pretty excellent. I looked around and some people suggested next cloud, which is really interesting. It's maybe more than I want. It's almost like a document calendar, everything self-hosted.
Maybe do that next. Yeah. Own cloud got like super owned just last week and is a similar self-hosted thing, which makes me a little nervous to self-host stuff. I know there are people host it for you, but it's not next cloud. It's a little bit indirect. So maybe violin. I don't know if you've heard of this, but they have encrypted, cloud storage and the end again, pretty nice.
Yeah. This isn't Wales. I mean, British, I mean, UK. Sorry folks. So that's pretty interesting. And I think, I think I'm going to go with sync.com. Super simple. All they do is sync and then encrypted for six terabytes. It's like 140 bucks a year or something like that, which is a lot, you know, versus 240 for less than that in Dropbox.
Have you heard of this, Brian? No. So cryptometer is cool. I have used something like it, but it's older and no longer supported, which makes me sad. So what you do is you run this app. It does like super strong encryption. You control the key, right? It's just like a thing you make up and don't give away.
So you put that in Dropbox, you put that in sync or whatever, and then no matter what happens, they just get an encrypted blob of stuff. So things I super care about, I have encrypted in something either cryptometer or something like it. On top of all the safety around the cloud drive and trust and whatever you might have there, like worst case scenario, they get a huge, hard, hard to decrypt a blob of stuff that they don't know the value of.
I mean, cool. But cryptometer would have been great as a rotten tomato sort of thing to rate different cryptocurrencies. I know. The word is taken. I'm pretty sure this has been around before crypto became a thing. I'm not sure how old this is. Yeah. There's 17 pages of releases on GitHub from 2017.
So yeah, they were ahead of their time in that. But yeah, this is super cool, Brian. Like you can just say, I don't really care that much about the security of where these files go. You're not getting them. Interesting. So I suggest a sweet combination of these things. I'm going through like a super digital decluttering as part of this.
So sorry about that. But shift command T. Oh, shift commit. Oh, whatever. I'll just tell you guys about it. So this is the kind of time of year that some people like to donate some money to different people, different groups. I had the link up for the Python Software Foundation. So Python Software Foundation is not hard to find.
So I would encourage people to consider giving some money to the PSF. So Django Software Foundation is doing a drive. So giving some money. If you use Django, of course. If you enjoy Python Bytes, of course, you can check out Patreon. At Patreon, we do accept money for Python Bytes to help keep the show going.
This is great. Also, I wanted to highlight as well just the idea that to just go on GitHub. So the different things you use on GitHub, like attrs, for instance, you can go down and you can sponsor this project. You can throw some money that way. pytest has a sponsor link. Pallets and Flask has a way to sponsor either all of Pallets or particular projects within the Pallets program.
And really, a lot of projects that you use every day have a sponsor of this project on GitHub. So I think it'd be great, too, for people. If you have extra and you want to help out, I think it's a good idea. Sometimes I help out different projects and I kind of shift it up every year and local things.
And I think the things that I use. And somebody asked me once recently about some projects don't really need the money. And I guess, for instance, I really love having people support Python Bytes through Patreon. It's fun to have our community help support us. If you, in particular, don't donate, we're not going to disappear.
You can press either of them. One of them says, pay $12. The other one says, admit to yourself, your dream is dead. There's somebody sweating trying to decide which button to press. And it's the domain renewal. Oh, yeah. Totally. This is way too close for home to home for me because I just transferred 25 domains from all the different places into hovers I talked about like a while ago.
I don't technically use it. It redirects to talk by thon.fm. But if I don't have it, someone will get it. And then all sorts of badness. Like there's a bunch of these cards. I would say half of them fall into that realm. Okay. And then maybe another third I'm directly using. And then there's the whatever the balance, the one six that's left is the dream could be dead.
Or it could be not there yet. Not realized yet. We'll see. I had about eight that I was not really using last year. And I admitted that about half of those are not going to go anywhere and let them expire. Let them go. Although, I mean, the domain companies don't make it easy. You're like, okay, I'm just going to let it expire.
But you get like emails. No, it's going to go. Oh, it's gone. But we're going to save it for you for a couple more months. And you get a whole bunch of guilt emails. But yeah. Anyway. Yeah. Yeah, exactly. I have one real quick sad story to round this out, Brian. Okay. A friend of mine and I decided we're going to write some iPhone apps right when the iPhone came out.
Never really came up with stuff. It looked like there was nothing on the horizon. We're like, you know, after three years, the LY, it was like the FM. It was like kind of expensive. Like, ah, just let it go. A week later, somebody says, hey, I'll give you $5,000 for that domain. So I shoot my friend like, hey, don't let it expire yet.
Let's do this instead. He's like, it expired last week. Like, no. Oh, no. Oh, well. So it goes. So somebody could have paid you $5,000, but they instead got it for like $20. Yeah, for like $20 or something. I'm sorry to laugh at your pain. No, it's okay. I mean, like, I'm telling you, this is not a joke.
