Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 418, recorded January 27th, 2025.
And I am Michael Kennedy.
And I am Brian Okken.
And this episode is brought to you by us.
Check out Brian's pytest course.
Check out his course and a bunch of my courses over at Talk Python Training.
And thank you to Patreon subscribers, supporters there.
We appreciate all of you.
And even if you don't do any of those things, we appreciate that you listen.
That's why we get to do this stuff.
You want to connect with us?
We're Bluesky Mastodon mostly these days.
Links for Brian, me and the show all in the show notes.
You can join us live, pythonbysetfm.com slash live.
A few of you are, most of you aren't.
That's fine.
But we do that if you want to join.
Usually Monday at 10 a.m. Pacific time.
Sometimes things go a little haywire.
You can always watch the video replay on the episode page if it's available.
And finally, Brian and I are crafting.
We're continuing to hone our artisan craft, Brian, for the artisan newsletter.
So if people want to get the newsletter, they can go right to Python by Setup M.
Click on newsletter.
It's the very center of the five buttons in the hero image.
And all you got to do is give us your name and email and we will send you summaries, insights, the joke.
And a couple of things we're doing different now.
Brian is trying to put the TLDR stuff at the front so you can skim it really quick as well as the joke so people can have fun with that kind of stuff.
So if they want that, they can check it out.
And with that, what would you like to talk about first today?
I actually want to talk about something that's not really wonderful, but I think we should talk about it anyway.
So this last weekend we lost Michael Ford.
And many of you might not know who that is, but he was influential.
He's a core Python dev and influential with a lot of the early stuff in Python and PyCon, at least early in my perspective.
So one of the things that he is known for is one of the contributors to the unit test library within Python.
And then also he wrote a package called mock that was separate for a while, but then I think it was 3.3 or something early in the 3xs got incorporated into the standard library as unit test.mock.
So if you're mocking anything, even if you use, so pytestMock is word I usually use often, but it's a wrapper around that library.
So a lot of great stuff from Michael.
He was a larger than life character.
There is an in memoriam that's up on the python.org discuss site started by Guido.
And a couple of things that Guido mentioned is that Michael was an original thinker, started the tradition of having the language summit events at PyCon.
That's pretty big.
And if I recall, the IRC was that, if I recall correctly, together with Barry Warsaw.
So he also wrote the mock library.
And in memoriam, so Guido suggests that to feel free to post positive memories of Michael.
And perhaps maybe he's got kids, 10 and 13, so hopefully later they can look back and see how influential he was.
And I really had a hard time with this, actually.
I had a couple losses in my family recently.
And I wasn't really close to Michael, but I kind of wished I would have been.
I did interview him.
I tried to interview him early and eventually did, in 2021, get to talk to him about mocking for the Testing Code podcast.
So just listen to this.
It's a great, again, it's a great episode.
He's got some great advice towards software development and testing.
So check that out also.
There's also a really great write-up from Nicholas Tollervie, who I also had on the Testing Code podcast.
Also a great guy.
He's the dude from the MU editor.
He wrote up my friend Michael a post about losing Michael.
And there's some great pictures.
He was a larger than life.
That's a great one.
Larger than life character.
There's a paragraph in here I wanted to read.
He was a walking paradox, both completely certain of himself and yet always questioning everything.
He didn't shy away from fiercely independent thinking, often about the oddest of subjects, and through the most extraordinary, original, and I dare say weird lines of argument.
Anyway, goodbye, Michael.
You will be missed.
Yeah, thoughts out to the whole community, friends, family.
I didn't get a chance to meet Michael, but certainly it looks like he was very influential.
Yeah.
Indeed.
All right.
Hopefully you got something a little less depressing next for us.
Yes.
Well, it starts with a real smiley picture, so it's going to start out pretty well.
I had Calvin Hendryx-Parker from Six Feet Up on Python, and we talked about this deployment system, kind of like Cookie Cutter, but way more than that.
A whole infrastructure for initially Django apps, but growing from there.
Anyway, during that, we talked about a bunch of the building blocks of those tools and of that framework.
And that's how we get to the next one, something called Valkey.
Do you remember, I mean, you know Redis, right?
So Redis, key value store, it's people sometimes group it in the database category for when you're doing like surveys and what database you use.
Redis, JSON, or SQL Server.
Like, huh, wonder which one I should pick.
Which of these fit and which of these don't or whatever.
But, you know, Redis is kind of a key value store, mostly in memory cache, high speed, but can be used for other things, for queues.
I believe it can persist.
Well, anyway, it's gone through some funky licensing.
This is not new, by the way.
This is not new.
But it's been that way for a little while, and I don't know.
I've always had prickly reactions with the folks from Redis, but whatever.
I ran across this thing called Valkey, like value key, key value store.
And Valkey is a truly open source, no license, no cost, no nothing alternative to Redis.
So an open source in-memory data store that can kind of be a primary database if you want it to be, but it's not its main goal.
So here, I'll just give you the quick first paragraph.
Valkey is an open source, high performance, key value data store that supports a variety of workloads, such as caching, primarily, right?
Message queues and can act as a primary database.
Valkey can run either as a standalone daemon or in a cluster, which is pretty awesome with replication and high availability options.
It even has native support for, well, strings, obviously, numbers, probably, but hashes, listsets, so you can ask for probably like, I want a query into this dictionary type of thing.
Pretty cool.
People can check it out if you go to the GitHub somewhere.
There's got to be a GitHub, right?
Here we go.
And you go to the repositories somewhere.
Oh, there it is right there.
Finally.
Found it.
18,000 GitHub stars, 700 forks.
So it's got a lot of life to it.
And let's see.
Does it tell you how old it was?
About a year old, I think.
Anyway, isn't that cool?
I think it's really neat.
Yeah, I'll definitely check this out.
I do too.
I'm pretty excited about it.
I'm not using anything like this yet, but there's some situations where I might be able to use this recently.
Certainly, this is something I would give a hard look at if I was doing a key value in memory cache type of thing, especially with the failover and the replication.
Because a lot of times, you've got to restart these things.
They have to repopulate the cache.
And that can be really kind of slow.
And, you know, you see systems fall down.
Then they can't quite get back up because the cache isn't there.
And they keep getting killed.
Anyway, these are pretty neat technologies if you need them.
And Valkey, yeah, check it out.
Cool.
All right.
Back to you.
Let's see.
Doing this again.
Okay.
I'm going to go back to Michael Ford again because actually in 2017, he wrote an article called 30 Best Practices for Software Development and Testing.
And I think I didn't talk about it on this podcast because my intent was to talk about it on Testing Code and interview Michael.
And that was a long story as to why we didn't talk about this.
But I can't believe we haven't covered this yet.
So a really great article, 30 Best Practices.
I'm not going to read all of them, but I want to read like a few of them.
Yagni, it's not the only place I've listened, heard the term Yagni, but Yagni is number one.
Yagni stands for you ain't going to need it.
So don't write code that you think that you might need in the future, but don't need yet.
Just don't do that.
You write it in the future because you might not need it.
Yeah.
People stress so much about this.
Like, oh, we got a plan for the future.
We got to get just right.
Or just embrace refactoring.
Just embrace refactoring.
Right?
Like write it so it works now.
And if you need to change it, there's all sorts of amazing tools to change it.
Source Control doesn't not break it so you can save it.
We'll refactor.
Just test to make sure it works.
Yep.
Going to jump down a little bit.
A bunch of great stuff in here.
Oh, I love this.
When it comes to API design, simple things should be simple.
Complex things should be possible.
I can't remember.
I don't remember if I got this from him or not, but I live by this.
Trying to keep the easy things easy.
And it can be complicated for the not easy things.
That's okay.
Number six is unit tests.
Unit tests test to the unit of behavior, not the unit of implementation.
And these are kind of fighting words.
This is pretty much the difference between classical versus Marcus test driven development.
But I stand by Michael's side on this one.
Number eight.
We've got a couple more that I want to hit.
Number eight.
Code is the enemy.
It can go wrong.
It needs maintenance.
Write less code.
Delete code.
Don't write code.
You don't need less code.
It's true.
The less code you got, the less bugs could be in there.
For the most part, as a general rule.
Last one that I want to cover.
More about nine as well, by the way.
Oh, nine.
Yeah.
Inevitably code comments become lies over time.
Yeah, definitely.
In practice, few people update comments.
I still remember that I had a code base that there's so many comments in them.
And there were boilerplate comments that in order to understand the code, I wrote a script
to copy the entire code base into a different directory structure.
and strip all the comments out.
And it was so much easier to deal with.
Gosh, I feel that way about help docs.
Help strings.
Doc strings sometimes.
Yeah.
It's like there's three lines of code and 18 lines of doc strings.
Like, wow.
If that just weren't there, I could read it.
Yeah.
And then that can blow up the entire file.
If each function is like that, you've got a few hundred lines of code and 2,000 lines
of file.
Anyway.
15.
We'll jump to 15.
The more you have to mock out to test your code, the worse your code is.
And that was one of the things that surprises me coming from him.
This is the dude that wrote the mock library.
And one of the things he discusses in the episode where I got to interview him is he was developing
this when he was on a team that was doing a mock test, you know, a mockist isolation test
driven development philosophy.
And they ran into the issues that I've run into before also is if you're testing the implementation,
that means when you have to refactor your code, your tests don't help at all.
They just all break.
So testing behavior is better.
And then also just trying to not have to mock your code.
That's not a hard and fast rule.
Sometimes it's the easiest thing.
So.
Yeah.
And plus you're going to hurt his feelings if you mock it.
It's just not nice.
I mean, sometimes you got to.
Just not nice.
It's just not nice.
Come on.
Yeah.
That's funny.
Anyway.
Great article.
Go have a read.
I've reposted it on social media and a lot of people have said, hey, this is great.
Awesome.
It's good.
All right.
I got a question for you, Brian.
Okay.
If you're working on a web project, and I've been working on some web projects, and you
have to do direct requests, like say, for example, over on Python Bytes, if I go to, say,
like our latest, which is very, very close to being not true, but our latest episode,
Bug Tied from the Light, you can see there's an image here.
And that's the thumbnail from YouTube.
And we have stuff in Python Bytes.fm that when you load this page, it'll look for the
YouTube link, and then it'll talk to YouTube.
Pull that and get the thumbnail.
Now, you might think, why don't you just put the YouTube embed right there?
Because Google is parasitic, and when you embed a YouTube video, it puts tracking cookies
onto you, which means we would have to have a cookie banner.
Do you accept our cookies?
Because we're making our website better for you by tracking you.
Like, I'm pretty sure you're not, but okay.
Or you could download the image, put it in your database, and then serve it out of court,
or Flask, or Pyramid, or whatever it is you're using, right?
Yeah.
When you do that kind of stuff, you need to know what the MIME type is, or the content
type, more importantly.
Like, you need to tell the browser, this is not just binary stuff, but this is an image.
I know it came from a database.
It doesn't have a file name, but it's a PNG, or it's a JPEG, or whatever, right?
So back to my item, MIME type.io, which I would prefer to say is content type.io.
But, you know, for example, tell me, what is the content type of a JPEG?
Well, it's probably image slash JPEG, but is there a E in there, like JPEG, or is it JPG?
Hmm.
But you better not get it wrong, right?
So there's this site, MIME type.io, and you just type in whatever file extension you think
you can imagine.
It'll tell you it's image slash JPEG with an E, not without.
And it shows you all the file type extensions for which this applies.
And it gives you, like, the history of it, what if there's other things it's known as.
Like, sometimes, I think if I put it in JSON, there might be, like, JSON is application slash
JSON, but there's a deprecated text slash JSON.
It might also appear as.
Isn't that cool?
Yeah.
So if you're doing web projects and you need to send files, you need to specify the content
type.
And here you go.
This is how you do it.
So I really like this.
I ran across this.
And I had tipped to a very, very similar project for HTTP status codes at HTTP statuses.io.
So, for example, you've seen 200, 201, like 200 is good.
201 is created if you did, like, post a new thing or whatever.
What is about 203?
I don't know, man.
But if you click on it, it says this is a, you know, lets you dive into them.
It's a 203 non-authoritative information.
This request was successful.
But the enclosed payload has been modified from that of the origin server's 200 OK response
by a transforming proxy.
Woo!
But it also shows you, like, how to get to these as enumerations in, say, Python or the
new new Python and so on.
Right?
So you're not programming with magic numbers like 203 or quote 203.
Sometimes these are representative strings, and I don't know why.
But yeah.
Anyway, we're going to come back to this for our joke.
But the takeaway is mime type.io, which I wish were called content type.io.
But whatever.
It still works.
Okay.
I like mime types.
Yeah.
Like the types that are stuck in a bubble.
Like, I can't get out.
I know.
Yeah.
They really do act it out.
They do act it out.
Sorry.
No, it's all right.
All right.
That's it for our main items, right?
Yeah, I think so.
You got any extras?
I just noticed, just one.
I noticed, sorry.
I noticed somebody posted online today that Python 1.1 is out.
Actually, 31 years ago, as of today, Python 1.1.
Yeah.
That's awesome.
On January 27th, 1994, Guido posted 1.00 is out.
So anyway.
I'm tired of deciphering that Perl code you got last week.
Sick of CGI.
Let's go.
Frustrated with born shell syntax.
Yeah.
Yeah, yeah, yeah, yeah.
Yeah.
Funny.
Cool.
Well, I don't know.
We'll see if that thing takes off.
Hope so.
It's got a feature.
We'll see.
All right, cool.
I got a few extras.
I'll keep it quick.
I don't got a lot.
Speaking of releases, Python 3.14.0 Alpha 4 came out last week, minutes after we recorded
our last episode.
So since last time, something to announce.
People can check it out.
It's coming along.
This is Alpha 4.
That means there's three more Alpha releases.
Then we hit beta.
Then you can start to treat it seriously as a fixed item, right?
Chances are no new features.
Just bug fixes and polish before it goes.
Although I'm sure they could decide, you know, this is too rough.
We're not going to make it.
We'll take a feature out.
But the idea is that the betas are fixed.
Yeah, and actually, so I usually haven't been testing new stuff until we had to betas.
But uv has made it so easy to load up pre-release stuff that I'm testing with 3.14 already.
That's awesome.
And it's not just easy.
It's also low impact.
It's not like you're taking over your machines.
The latest Python is now this Alpha thing.
Yeah, right.
Yeah, yeah.
Same goes true for free-threaded Python, right?
You can get that with uv.
Pretty cool.
All right.
This wasn't even going to be here, but then I was thinking about it as we were setting up.
I just set up a Fastmail account.
And wow, Fastmail is so much better than Protonmail for what I've been doing these days.
Like Protonmail is always slow and clunky and even things like archiving.
Like they have a hotkey to archive your mail.
And you're viewing the mail and you press archive.
It's like three seconds later before it archives it and it goes away.
Like what is it doing?
So I've switched my personal mail over to Fastmail.
And so far, I highly recommend it.
Yeah, I've been using it for a while.
I love it.
You like it?
Yeah.
I'm really enjoying it as well.
Okay.
Well, that brings us to our joke.
Okay.
And back to HTTP status codes.
What episode is it, Brian?
I don't remember.
418.
Well, let's go down to status code 418.
And there was somebody in one of the socials, Mastodon or Bluesky, I can't remember,
I believe, who said, it's coming up.
It's coming up.
You got to do this.
Oh, yeah.
They were still right.
And they gave us a picture.
I can't find the post again.
So I'm sorry.
I can't shout out credit.
But thank you for sending that in.
htpstatuses.io slash 418.
418.
Client error.
418.
I'm a teapot.
This is literally in the HTTP spec.
You can return it for whatever value it serves.
418.
I'm a teapot.
Any attempt to brew coffee with a teapot should result in an error code.
418.
I'm a teapot.
The resulting entity body.
may be short and stout.
I am quite disappointed in Python.
I am disappointed.
There's a .NET enumeration.
Status code.
Status.
418.
I'm a teapot.
There's a Rust.
I'm a teapot.
There's a Go.
Status teapot.
There's no Python.
I'm a teapot.
They didn't implement all of the status codes.
Come on, people.
Oh, dear.
This could be my first pep, Ryan.
Yeah.
I think you should do this as a pep.
I got to get this accepted.
Yeah.
So one, it's funny.
But also, do you think it's in place just for something for people to debug their status codes?
Yeah.
Possibly.
I'm pretty sure it was an April Fool's joke that got into the spec, and people are like,
we're doing it.
Yeah.
We just have to keep it.
I'm a teapot.
This is a perfect status code.
So this is I'm a teapot episode.
I mean, show title right there.
What do you think?
Yeah, definitely.
Number 418.
I'm a teapot.
Let's go.
All right.
Hopefully, the RSS readers will still get it.
I know.
Will they read the 200 OK on the RSS, or will they read the title?
The 418.
We'll see.
And there we go.
We're sorry.
Your podcast letter is not short and stout.
Yeah.
I hope so.
No, I hope it actually works.
Awesome.
We'll see where it goes.
But that was a lot of fun, as has been doing this show for 418 episodes.
So thanks for being here.
Yeah.
Thank you.
Yeah.
And thanks to everyone who listens.
Bye.