Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
your earbuds. This is episode 414, recorded December 16th, 2024. I'm Michael Kennedy.
And I'm Brian Okken.
And this episode is brought to you by us, all of our things, books, courses, stuff like that.
We have many things for you to get better at Python. Check them out, links at the top of the
show. And we are now pretty active on Blue Sky. Brian, thanks for dragging me over. And I want
to point out that you can go to my profile and click on Starter Pack. And there's a bunch of Python
people. If you click that, you follow me, you follow Brian, you follow the podcast, plus something
like 60 other noteworthy Python people like Samuel Colvin and others. So that's a real quick and easy
way to jump in there and kind of get going on that.
Starter Packs are pretty cool.
Starter Packs are a really cool growth hack for Blue Sky. Yeah.
Yeah.
Blue Sky is fun. I'm enjoying it over there. I'm wondering if the surge of momentum is starting
to fade a little bit, but we'll see. I know people are excited and I think it's a great place. So
I encourage people to check it out. If you would like to get every week, all the show notes and
links and everything delivered to your inbox, even if you don't happen to listen that week, which I
don't know why that would happen, Brian. That would be a big mistake.
That'd be weird.
It would be very weird. But even then, if you go to Python by set of M, click on newsletter,
enter your information. Well, then Brian will send you a handcrafted, artisanal version of
the show notes. So very awesome. I did say heavy, Django heavy, didn't I, Brian?
Yeah.
Let's start. Let's start with Django.
Well, we're going to start with a small item, but I think it's going to affect me right away. So Jeff
Triplett announced he's got a new project to shorten Django-admin to just Django. And what we're
talking about isn't the admin section of Django. It's just the command. So the thing, like on the command
line, I have it up in like a tutorial. So like, like for instance, the Django tutorial, there's,
there's, there's a bunch of Django admin command line things that you have to run like start project
or, and a bunch of other stuff too. So if you type Django-admin and some stuff like that,
and you've ever thought, why can't I just type Django to do this? Jeff has thought that too. So that
this new project just makes it so that you, you just pip install it with your stuff. And then you,
you don't have to use Django admin anymore. You can just use Django for, for the, the command line
thing. So the, and the idea, I mean, it's a, it's a great idea. And he does say in his, we've got a
blog post announcing it that he would like to see this in the normal Django, but the Django-admin won't
go away anytime because it's already been there for 20 years or more. So, but it'd be great if it
was just like this, because why not? Yeah. That'd be amazing. I don't see why you couldn't have them
both. And I think, I mean, what other commands do you type Django on the command line and do stuff for
most people, right? Yeah, exactly. You just take it. Yeah. So exactly. And you can have multiple entry
points in the Django package when you install it, which will give you both commands as you see fit. So
yeah, let's do it. Yeah. Also I've been doing a lot of Django lately and I appreciate just,
it's half the characters. If I counted them, he mentioned it's half the characters. I'm like,
really? Yep. It's not just half the characters, even more significantly, it's the dash, right? Which
requires like a incantation on your keyboard a little bit. Yeah. The different, yeah. It's not as fast to
type. So yeah. Thanks Jeff. So I would like to ask you, Brian, having done some Django lately,
have you seen any unicorns? Yeah. No. Because I have. I saw a Pegasus, but not a unicorn. Yes. The
Pegasus. That is like a unicorn, but I don't believe it has a horn or as much magical powers. Okay.
I'm not entirely sure of the mythology of Pegasi versus unicorns, but the magical reactive component
framework for Django is the Django unicorn. This is pretty neat. I just learned about this. Let's see,
is it, it's, it's not super new. I just, it's super new to me. Okay. So the idea here is that it's a
little bit like a JavaScript front end framework, like react or something, but you can avoid using
it, right? You can avoid writing your own JavaScript front end. Instead, you can just pip install Django
unicorn, add it as an app. And then you've got to include it scripts and so on. But somewhere down
here, you can use these unicorn attribute modifiers in your template, right? You can say unicorn submit.prevent
add, add, and then instead tie that to, if I don't scroll too quickly, you can tie that to a model
called task. And if you hit escape, what does it do? It'll change, like replace the task text with that,
this thing right here, right? And you can just add a button when you click this, call the function add
and so on. And then what you do is you go and you create like a form object and an item that maps to it.
And then it just automatically wires together the creation of, of these, let's see, where's the
example. So yeah, not enough here on the little example on the homepage for me to totally know
exactly how it works. But basically when you interact with this UI element, it maps to rest functions
implemented by the unicorn thing automatically, right? So you can just include some, it's a little bit
like HCMX. You just include some magical text on there and it'll call back to the server. But the
difference is it'll handle it on the server as well. Right. So pretty neat. Yeah. So if it says,
is it magic? Sort of feels like it, it progressively enhances normal Django views with the initial render
being server side rendering, which is like I said, like HTMX as well, depends how you use it, but it
can be. So it's good for SEO. It just the pure HTML content is there. It's not just like angle
brackets everywhere. When you view source, it binds the elements you specify automatically and makes the
Ajax calls on its own when it needs it. And it comes back and it updates the DOM when the HTML changes
or with the HTML changes. So yeah, just write normal Django type stuff. And it takes it, it says,
it also has other features, form validation, redirections, dirty states, partial updates, polling,
etc. And then down here somewhere, maybe it's in the docs. It says, here's what you might do instead.
Right. You might have to use reactor. You might have to use this other thing. Unfortunately, I think
that's here on this page. It says what else you might have to use. Yeah, there's better examples on
their landing page. It gives you sort of a comparison to view, react, etc. What is notably lacking here is
HTML, which like I said, is kind of like it. But nonetheless, if people are doing Django and they
want something like viewer react, but they don't really want to do JavaScript, this could be a pretty
interesting thing to check out 2400 GitHub stars, pretty decent. And this is and this is a fairly basic,
like low learning curve to just try to it might be enough before you jump into something else. So
Yeah, absolutely. And by the way, real time follow up on your, your item. This is what I thought when I
heard about the Django admin, Pat Decker just says alias Django equals Django dash admin. And that's
exactly I'm like, yep, I have so many things like that. Like that's a huge long command. That is
alias to two or two letters. Okay, fine. I could do that also. But but it's nice. I mean, why why impose
the longer version on everybody until they get either think about it or you know, a lot of people are new
when they take these tutorials, they don't know that they can do that kind of stuff.
Right. Or you might be like on Windows, and I have no idea how to alias anything on Windows.
So batch files, it's all batch files. All right, over to you.
Oh, what am I talking about? I wanted to talk about testing a little bit. I had fun time reading
this article from Ned Batchelder called testing some tidbits. So this is sort of a fun thing. So he posted,
he just posted, like, let's say you had this, you wanted to, he wanted to look at different ways to
check to see if a string only had zeros or ones in it, and nothing else. And there's a lot of ways you
could do this. He presented, let's see, one, two, three, four, five, six different ways in a post on
both Mastodon and Blue Sky. And then he got a whole bunch of replies saying, like other ways to do it.
And, and one, it's kind of a fun, just like, like, how would I do this sort of thing? And there's a lot
of ways to handle it, which is fun. Anyway, so he, he also wanted to test how to do it. And since
there's testing in the title, I thought maybe he'd use my test or something. But yeah, no, he's got
like a set of good input that should be just all zeros and ones. And then a set of bad input that has,
you know, it's not all, and some of it's like a whole bunch of zeros and just one non zero. The
empty string is used. That would be considered good. And then I, even a thousand character,
a rain, a string with a thousand characters in it or 10,000, it's 10,000. Wow. So big, long string.
So, and then a whole bunch of different ways that he had, he has original checks, but plus a whole
bunch of others that other people used. And then his, he just runs through them. But that one of the
things I really loved about this is I learned some stuff about pytest or Python. I learned about
clean doc from inspect.clean doc. It's a way to strip out a white space that I usually use. What did I use?
I use, usually used a like text rapid D dent for something like this, but so I'm going to have to
run some testing to find out which one deals with stuff better clean doc. That might be better. Yeah,
that's cool. And then there's a partitioning. I don't use partition much, so I couldn't, I didn't
remember what that does. So partition, he was using partition to strip out comments. And what it does is
split a string on, on whatever you pass it in, in this case, the pound sign or, or hash or whatever
you want to call it. And then he used a, and then it splits that into three strings before the, before
the delimiter, what the delimiter was and after. And so this is, this is a way to just grab everything
before the comment, which is cool. And then he used, what else did I learn? Oh, I didn't understand what
this if not test is in here for first, but this was checking for blank lines, which makes sense or
stuff with just a comment. But then there's this eval, which I am so afraid of evals, but in this case,
you're writing the stuff it's from right here. So it's pretty safe, but eval the code and then passing
in a variable like the S variable into the code. So everywhere in this code, you're the S means the
string you're passing in, but this or G, what does or G do? And what he's doing is it's, it's a way
with eval to pass in imported stuff. So it imports, it'll import the regular expression and the counter
modules into the eval statement. So I didn't know you could do that. So I was thinking bitwise or
yeah. No, it's a way to get these imports in there, which is pretty cool. Anyway, that's fun.
And then he lists some other ways, but I was still frustrated that there's no pytest in here.
So I thought, how would I do this with pytest? So I just wrote up a quick blog post, actually just
praising Ned as well, because I learned some stuff and I like learning new things. But then what did I
do? I imported pytest, the same imports that he used, and then the, the same good and bad and tests.
But then I just split it up a bit different and used parameterization to write the test code. So
if anybody wants to use pytest instead, here we go. The excellent, the one fun thing that I had was this
10,000 character I'm using with parameterization. I was able to take the, the input as part of when you,
you do pytest dash fee, it prints out all this. It's the parameterization prints out, which is nice. But I
I didn't want 10,000 characters printed out. So I also got to use the ID function to shorten that up a
bit, shorted it to 20 characters. But anyway, testing.
Very nice. Yeah. I love the compare and contrast as well.
Yeah. Yeah. Awesome. Let's talk some trends, huh?
Okay.
So this was originally just going to be an extra. The more I looked at them, like this actually could be a fun
conversation for you and me to have. So I wrote a article for the JetBrains blog called "The State
of Python in 2024." Okay.
I thought that'd be pretty fun. And there's eight key trends or whatever I pulled out. So I thought,
hey, you know, maybe, maybe that'd be fun to talk about the eight trends and get your thoughts on it.
All right. So let's do it real quick. So first of all, Python keeps growing. But it's interesting
that actually, if you look at the amount of other languages used along with Python, they're decreasing.
Right? So for example, in 2021, 40% of Python people did JavaScript plus Python. Now it's only 35.
If you look at Bash, 33% of people did. Now 29 do. And a lot of languages are going down like that,
except for Rust. So that's pretty interesting. And that's because so many people are coming into Python
from non-traditional programming languages like data science and other scientists and so on. You know,
GitHub just announced that, I think we covered this, that GitHub said that Python is the most popular
language on GitHub now. It's pretty awesome. But most of those people are coming from non-traditional
backgrounds, meaning they're just going into like Jupyter Notebooks or something like that, right?
Like this is their only Py programming language is Python.
Yes, exactly. Exactly. They're like, they just became programmers. So they're not doing the other
stuff. So it's interesting to see these like, hey, you're doing less JavaScript as a community,
which is kind of the opposite of what I would imagine. And very, very closely to what you said,
41% of Python developers have been working professionally in any language for less than two years.
Like almost everyone is new here.
Yeah. And actually, I remember somebody talking about this, this, this question,
like maybe it was a different question, but like how long have you been a professional Python developer?
And a lot of people taking this survey don't think of themselves as developers. They think of themselves as just some other job. They happen to use programming also.
Yeah, exactly. So yeah. And then if you throw in three to five years at like, that's pretty much it.
Yeah. Trend three.
Oh, let's go up to the years again. Where are we at?
Oh, just 11 plus. So we're just in one bucket of 13% of the people.
And even so that's only like over 10 years is basically only 13%, which is wild.
Yeah, that's really wild. Yeah, yeah, yeah. Where do people learn Python? They learn it on YouTube,
on our John codes, and coding. And if they listen to podcasts, talk Python to me, who's the number one out there.
Nice. But I'm sure Python buys us just under, just under. Trend four, Python two versus three,
that's over. We've raged on about the legacy Python long enough. There will be no 2.8 says Guido all
the way back in 2014. Right. But if you look at it, it's like asymptotically, like whoever's still
on Python two, they just, those people aren't leaving.
Yeah. It's what's surprising to me is the people that are still on that and are participating in
surveys. I think they just fully have checked out. I imagine a lot of those people, which is 6%
for this year that are still on Python two, that they're on some huge project. I know there's some,
they're not going to migrate the project. The project will not migrate, but those people would
very much like to, and they probably in their spare time work with him FastAPI and other modern things.
But when they go back to work, they're here. You know what I mean?
Yeah. Or at least some of their project is using that. Yeah.
Yeah, exactly. But still, let's keep going. All right. Flask, Django and FastAPI are all the top
three frameworks, which is nearly a dead heat, which is pretty interesting. We just talked a lot about
Django. But what's interesting is if you ask web developers who are Python people,
not just Python people, but we talked about there's a lot of people who don't consider themselves
like developers or whatever. But if you say, hey, web developers who are also Python people,
Django is used one and a half times as much as Flask or FastAPI.
Oh, yeah.
So amongst the web developers, Django is clearly leading the pack. But amongst data scientists,
Flask and FastAPI are ahead because they're more about building APIs and getting their models online
and so on. So that's a pretty interesting difference, right?
Yeah. And I'm thinking there's a lot of data or data science stuff that doesn't have a back
database or anything or some huge thing. Yeah.
Yeah. Where do you host your stuff? It's all about the hyperscale clouds, apparently, which is
blowing my mind, actually. AWS, Google Cloud and Azure represent, gosh, how much did it say?
I wrote it out maybe at the top. Represent something like 78% of where people host their code. Yeah,
78% are on one of the three massive clouds. Wow.
Hetzner is showing up.
Hetzner is there. Yeah. I mean, we put a dent in Hetzner.
We definitely did. We got one server there. Yeah. And also Heroku interestingly went down,
but I think that's because when they canceled their free tier, a lot of people stopped. They
decided to turn off their for move elsewhere. But Python Anywhere is going strong, actually,
above all the other small providers, right? DigitalOcean, Hetzner, Linode, and so on.
Python Anywhere. Interesting.
Yeah. Yeah. That's pretty wild, right? All right. Two more. People prefer containers over VMs and
they prefer VMs over bare hardware. That shouldn't be a surprise, should it? I mean,
maybe the containers versus VMs, but certainly not just straight hardware. Straight hardware is not
even on the picture, by the way. It's like lower. And last trend of 2024 is uv takes the Python
packaging, takes Python packaging by store. Yes.
I think that's obviously it's, we've covered it a bunch of times. It's not just that it's fast.
It's that it combines a bunch of functionality from different tools into different places. Yeah.
It's super neat. It installs Python. It installs, it creates virtual environments. It manages projects,
if you wish. It updates. There's a lot of, a lot of good stuff there.
And anyway, I think a big part of the uv uptick is the uv team tried to make it so that you could use
it with your current workflow. You didn't really have to change your workflow.
Yeah. I think that is very much an important part of it. That's why I adopted it for sure.
So, yeah. So anyway, these are, these are my trends. Hopefully people find those interesting.
There's a lot of like writing and data to back that up in the link.
Right. Yeah. All right. Yeah.
Yeah. Extra.
I've just got.
We've come to extras.
I just got one extra toggling back to Django just for a moment is I noticed that Django admin has a
Dracula theme now under the Dracula theme.com. And I can't, I can't remember where I learned it from.
One of the maintainers posted this on, on, on blue sky, I think. But anyway, it looks great.
Great colors. And I also, because of this learned that there is a thing called Dracula theme.com that
contains like a whole bunch of different projects that all have Dracula theme. So.
Oh, nice. So let's see what I love it. Yeah. And it has cool bats. Oh no. No pad plus. That's funny.
Nice. VS Code. Cool. Yeah. Yeah. Obviously. Obviously. no visual studio. Oh, oh yeah. I guess people use visual studio still.
Um, anyway. Yeah. viewer on windows. Yeah.
Yeah. Jet brains. Of course. Nice. Cool. So yeah, I had no idea about this site. That's super cool.
That's fun.
How about extras for you? I have a couple. Let's see here. First of all, my Zen browser experiment is
still going strong. I'm absolutely loving the Zen browser. It's based on Firefox, which I really like.
Okay. But that also means that you're limited to the Firefox limitations. Like I can't use it for our
live stream because our live stream only supports Chrome, which really means Chromium based browsers.
Right? So I, there's certain times that I'm not using it, but yeah, I'm enjoying people can check that out.
I feel, I talked to somebody and they're like, this is what Firefox should have built. This is like fire.
Why is Firefox not doing this? Yeah. You know, it's, it's a good question. I do think I honestly,
you know, as sort of a sidebar, I'm, I'm a little worried what's going to happen to Mozilla and
Firefox if the antitrust thing against Google goes through, right? Because if that goes through 90% of
Mozilla's revenue instantly gets declared illegal and cut off, not illegal for Firefox and Mozilla,
but illegal for Google. So they would have to stop. Right? Yeah. Maybe I'm not following that. So,
well, one of the big problems is Google has used their monopoly and their money and all that to buy
off locations to basically pay to either be the default or to prevent competition in different
ways. For example, they're paying something like $23 billion to Apple to be the default search engine,
not just in Safari on iOS, but in, if you go to Siri and you ask it a question, right? Like where does it,
it says, Oh, here, I'm going to search the web for you. Like, how do you think it's going to search
the web? Yeah, that's paid. That's okay. Right. But they're also paying, I don't remember the number,
but it's 90% of the revenue of Mozilla to support Mozilla. But I, you know, there's a lot of
thinking that that is to, to be the default search engine on Firefox. Right. But so that would make
it illegal for them to do that. Okay. It's the double whammy of like, they're kind of paying Mozilla to
keep Firefox around so they can say that there's competition. Yeah. Right. But if they can no longer
pay Mozilla to be the default search engine. Hmm. It's fishy though. If is there really competition
when you're only competitors paying you to be there? I know it's well, I mean, why is there a lawsuit?
Right? Yeah. So we'll, we'll see. Anyway. I think it's really cool. I'm enjoying it. Still a big fan of
Vivaldi as well, which is what I'm talking to you around on right now. Yeah. But also, did you know that
Microsoft has a browser? I heard of that. Oh, you know what? It's actually just based on Chrome.
Although Google doesn't pay for that one. I don't believe. Okay. I bet you get Bing as your default
search engine there. All right. refresh my desk setup. I just, I really, I'm enjoying this way more.
I set up a little separate table and a little separate computer. So I have a nice view. So I'm not
looking at like cameras and lights and junk all day. Oh, wow. Even if they're turned off,
I'm still just staring at a wall with like sound padding and stuff. And I enjoy it way more than
I realized. And I just want to encourage people. Like you're kind of frustrated with where you're
sitting, where you're looking while you're at work. Like maybe it's not that much work. It took a couple
hours. So I can look at trees instead of recording foam, which I encourage. All right. And while I was
sitting at this fun new desk, Brian, I added a really cool feature to our RSS feed. When I realized that,
there's an updated spec to RSS, which allows you to specify transcripts in subtitle format. So VTT,
web VTT or SRT files. Right. Okay.
So I added those to our set of transcripts to the website supplies to RSS feed. And now you get real
time follow along as you and I speak transcripts. Oh, wow.
And that cool. So you can just say, show the transcripts. And it's kind of like a Spotify or
YouTube music. It's just like follows along as we speak in the real transcripts. And I think you can
even search them. Although that's probably a per player type of thing. So this doesn't work in
overcast sadly, but it does work as far as I can tell in Apple podcasts and pocket casts. So at least
in those two, if you see a little transcript thing and you click it, that means it's going to follow
along in real time with our conversation. I wanted to have the little bouncy ball, like,
like, you know, the singalong movies when we're kids.
Boop, boop, boop, boop. Yeah, exactly. And, it works really good on an iPad. Like you can have
the, the view of the control and the art and everything. And then next to it, it has.
Oh, nice. Yeah. Yeah. But it's still also works on the phone. All right. that's it for my extras.
All right. Oh, I just wanted to add, it took five days to generate those transcripts with the computer
running 24 hours a day. So I regenerated these cause only, only maybe a third of our episodes had
VTT format. They had a different format. Just, it's like a pure text type thing that our website
understands and people can read. But VTT is more of us. It's like not JSON, but imagine like,
here's your JSON transcript to read, right? It would feel a little bit like that. Yeah. So I've always
thought of VTT is like some extra setting that is completely useless because I'd never use it. So,
um, so I'm glad that you are. You could use SRT. Those are the two that are supported here. Those are
like the two well-known subtitle formats or whatever. But yeah, I fired up. I have my old M1 Mac mini
laying around and I'm like, I'm just going to go over there and have it generate these for Python
bytes and talk Python five days later. It was done. And then I have a whole bunch of Python software
that goes through and like correct stuff. Like Ruff formatter is like R O U G H. I'm like,
no, not really. That's not what we meant to say. And it'll sometimes get your, you'll be Brian Aiken.
I'm like, Nope, we're going to fix that. And so on. Sometimes I'm Brian Aiken.
I don't know.
Oh, we're good. Oh, I'm Aiken.
Yeah. So there's a lot of work that went in to make this happen. So hopefully people enjoy it. And
yeah, cool. Thanks for it. And I appreciate you keeping improving the back, the back end of Python
bytes. So yeah, you're welcome. No problem. Okay. You know what? If you were,
if you were working on software, you taught, you started this show off with testing, right?
Yeah. Well, if, if no, you start off with the jingle, but we did talk a lot about testing.
Second item. Anyway, if you were doing testing and you wanted to make sure your tests pass,
you have many options, Brian, you could not run the test, but if the tests are going to run and say
continuous integration, whoa, boy, you better make those tests pass or continuous integration is going to
fail. So Martin Bettman shared this joke with us on blue sky said, how about Volkswagen? You know,
they kind of gotten a little bit of trouble for writing their car software to say, yes, these diesels,
they're so clean. You should absolutely get clean diesel, not dirty diesel, get a Volkswagen. What
that really meant was while it's under test, it's going to change how it behaves to have a better
emissions test than not. Right? So this is riffing on that and says, Volkswagen, this is a thing you
can install into your apps is it detects when your tests are being run in a CI server and make sure they
pass. Okay, I got to check this out. That's hilarious. Yeah, it says why? Well, if you want your software
to be adopted by Americans, because that's where VW got caught for their cheating, test scores from the CI
server are very important. Volkswagen uses a defeat device to detect when it's being tested in CI server
will automatically reduce the errors to an acceptable level for the test to pass. This allows you to spend
less time worrying about testing and more time enjoying the good life as a trust, trustful software
developer. They even have a badge like a read me for your GitHub read me. Yeah, with a build passing with
a little Volkswagen symbol. That's great. Works for Travis CI, Circle CI, Jenkins, Hudson's Bamboo, Team
City, TFS, Visual Studio Online CI, GitLab, etc., etc., etc. And it defeats assert, tap, tape, and shy.
And any actual, any test actually that is set to exit code or throw an error. That's funny.
That's bad, right? I gotta check out and see all the ways they're doing it. Yeah.
I know. I was wondering like, how does this actually work? People don't really do this. It's a joke.
Well, so I've actually had cases where, especially during development, where I didn't want the CI to
jump out at the end of the test, even if there's failures. So there is a pytest feature where you
can change the exit code. It's a pytest custom exit code internal plugin or something.
pytest dash always exit zero?
Pretty much, yeah. To override the exit code so that you can debug the rest of the tool chain
or get data on something. But yeah.
That's the only time I've done that. But that's funny.
It's a little, the image or the logo of it or whatever is like a little Volkswagen bug from
the 70s that transforms into a transformer robot. I'm using.
Nice.
There's 13 contributors to this. There's 15 releases. What is this?
How many stars?
Okay, okay. Let's find out.
Oh, 15,000 stars.
People are using this thing. Oh my goodness.
Or just amused by it. It's been nine years old or something.
Yeah, it has been around for a while, but I ran across this and thought it's pretty funny.
So this is good. Yeah.
Yeah. All right. Well, as always, thanks for being here. Thanks everyone for listening.
Thank you.
Bye.