Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
your earbuds. This is episode 354, recorded September 26th, 2023. I'm Michael Kennedy.
And I'm Brian Okken. I am good. It's been a busy week and it's only Tuesday.
I know. And it's starting strong. If you want to follow the show, stay in touch with us.
Be sure to check out Bastodon over on Mastodon. We got all the links for that in the show notes.
I was just thinking today, I just booked a couple of episodes through Mastodon for Talk Python. I just
was working on another video presentation thing on Mastodon. How much work gets actually done on
Mastodon. So people should be there with us, Brian. Yeah, I think so. Yeah, for sure. For sure. It's
the place where all the cool kids are. Indeed. Indeed. So hopefully you'll connect with us over
there as well. Very exciting stuff. See some people in the audience here. I'm going to have to give
them a shout out later because some things that we're sharing. And so that's going to be very
exciting. So speaking of exciting, what's the first thing you got for us?
I'm actually really excited. I may be jumping the gun on this, but Log Merger is from Paul Maguire. And it's a project that he's working on. And it's pretty fun. It's so I don't know. Maybe I'm not. I think more people, a lot of people deal with log files that they have to deal with more than one. So you have maybe two processes or three that are all timestamping and saving. Well, so this is a project that is
is a textual based project, but it combines them all and sorts the multiple logs based on timestamp. So you've got to see you've got maybe you've got a timestamp and then content and it splits it out and in and shows you the timestamp on the left and then the different log files in columns.
And the example just shows two, but I think you can pass it more than more than two. I think you can do multiples. So it's, it's called log merger, but it's not. It doesn't. I don't know if it actually merges them, but it makes this combined output thing. And it's really kind of fun.
It's more look at them in a merge, what a merge view with timestamps would look like rather than actually. Yeah. About trying to unify them or something. Huh? And I had some concerns right away and they were already like, I, I downloaded it and I'm trying this out. the, you can pipe the output to standard output, or you can use the textual thing. So you can do either one. so the output is nice, but sometimes, you know, log files can be huge.
And you only want to look at a part of it. So there's a cool, there's some, some nice flags that they're included. There's a start and end timestamp. So where you can say, yeah, start here and then go to here and don't do the rest of it. there's an interactive mode, which is, I think the default. Yeah. That, that shows you the little two and you can do error boxes and stuff. you can save them to a CSV. I don't, I think that'd be great if you want to throw it in Excel or something like that. and then multiple timestamp formats are
supported. So, so you've got like, there's a handful that I think this is pretty good. This is the standard ones. I didn't even pass in a timestamp when I tried it out and it just worked fine. so I'm going to be using this a lot. The, the, because I'm excited about some of the upcoming work. So there's, possibly, oh, maybe it's not here, but somewhere else. there's a possibility of using PCAP files. I think that's in working on those are, I don't know.
or even remember what that stands for, but I deal with them for protocol, analysis. but the, the, I maybe jumped the gun because you can't pip install it yet. You have to right now you download the code, but it's totally usable and runnable. so I, I think it's worth checking out, but it's, oh gosh, it's new. It's like,
you probably could pip install with the get. Oh yeah. With the get plus exactly. Yeah. With the get plus.
Exactly. I forgot about that. So you can do, yeah. So, I guess, Paul, people are using this.
At least I am already. So maybe like a little, maybe I'll do a merge request to add the read me to say
how to install it for now. So cool. Fun. Yeah. Nice. And prior guest on the show,
Michael Larson says, whoa, packet capture files. Is that the accentuating for it? That's awesome.
I'm going to need to check that out. Yeah. And Jeff out in the audience says, does it support time zones?
It does have a time zone display feature, but I don't know if the sort considers time zones or not.
Well, it might, my thing is going to be that they're going to be a little off anyway, because
sometimes the, the different, I've got log files getting generated by multiple computers that are,
the timestamps off by a little bit. but yeah, it's close. It's usually close enough to line
them up. Yeah. So close enough. Yeah. I do stuff like this as well. Like for all the talk Python
web properties. you get lots of requests and the engine X files have like a two week rolling
average. The most recent one is a straight log file, but the rest are G zipped by day.
Okay. So I have a Python script that downloads all of those unzips. The ones that are zipped,
puts them all together, then loads all of those files, sorts them by timestamp, and then like
creates one super log file, maybe a pending onto a previous one. So I have like single log text log
files that are the full month, month by month for analytics. Cause you know, we turned off Google
analytics and all sorts of other things because those are evil. Yeah. But you still want to know
like, well, how many requests were there to this page or to this episode page or like where, you know,
stuff like that, right. Those, those kinds of things are relevant. So yeah, this is, this looks
interesting. I had to write a bunch of code to do similar stuff. Although for 14 log files, you wouldn't
try to visualize them. You want to, I just want to turn them into one mega log file so that I can run
analytics across them. It's not on this read me, but I think when I was looking at it, I think there's,
there's recent stuff being done and I think that you can pass it GZIP files. I think it pulls them
out. It seems reasonable. Those are, frequent formats, I suppose. Anyway. All right. Cool. Good
find. Very interesting one. People in the audience like it as well. This next one comes to us from
Hugo VK and not, not sent in. I just discovered it, I believe it's hello. Python main library maintainers.
So if you have a PI PI thing, if you twine or what upload those types of things,
you probably want to pay attention because I said, because everyone was so good at finding
bugs last time in the Python 3.11 release candidate, the third and final release candidate is now out.
Please give it a spin. It's your last chance to find, significant problems, right? Critical
problems. And goes on to point out, here is a nice article on how to test it, how you can get the
release candidate. And basically how do you test your libraries with this? And it goes through like,
how do you set up a GitHub action so that it will use the 3.12 free release, right? Yeah. how do you do
it from dead snakes? How do you do it for Travis CI or other CIs and different things in here? So that's cool.
That'll help some people set it up into their CI. There's also a big long discussion here. So Thomas
orders, points out that at least candidate three is here as a reminder until it's, until the final
release of 3.12, zero, the release 3.12 branches set up. So the release manager has to merge to the changes,
right? So reach out at this point, unless something critical comes up, it should really only be
documentation. Other changes will be pushed to 3.12.1 and somewhere in here, there is, yeah, the intent.
This is exciting. The intent is for the final release of 3.12.0 scheduled for Monday, October 2nd. That is
like the coming Monday. Yeah. Unless you, if you're on top of your Python bytes playlist, don't let that thing
fall behind. Then the coming Monday, you know, October 2nd is going to be when this thing releases. So that's
pretty excellent. I guess bringing back to the first part, this is basically you have a couple days to make sure
that your library will have no hiccups when Python 3.11 ships. So, or C3.12 kind of gets used to saying 3.12.
When that ships, in a week, you want to make sure that your stuff just works. So here's your chance and a few steps on
how to do that. Yeah. Because you know how nice people are in GitHub. You'll get issues right away.
Hey, your stuff doesn't work on 3.12. You might even get like some hot October amazingness. Like,
Hey, you were using the wrong preposition here. I changed it. Like, well, that was not wrong,
but this is not a real commit. Yeah. Seth is back to say, highly recommend the setup. Python allow pre-releases
feature that lets you set up a forever pre-release testing job. If you use a Python version 3.x,
that's pretty, pretty good advice there. Yeah. Cool.
Neat. I don't think I use that. I'll also check it out.
Well, now, now, you know, you can.
Yeah. All right. All right. What else do you got as exciting for us?
Okay.
What other good advice do you have?
Uh, what do I got? I got, oh, good advice. I think I have questionable advice.
but I like this pattern. So I I'm, linking to, James coffee blog with,
the Python dictionary dispatch pattern. And I just like this cause I don't know if it's not discussed
much in like beginning teaching Python stuff is to, but, you know, if you're a C programmer,
use jump tables or maybe you shouldn't use jump tables, but jump tables are fun and C, and you can
kind of use them in Python too, but they're, they're a little bit, easier to use. Yeah. I just have,
dictionaries, that dictionaries can store anything and they can include functions. So,
he has an example of just add, subtract, and multiply, which you wouldn't really use for that, but
it's just an example. And I kind of forget that you can throw lambdas in because you can assign the
lambdas have a value. So you can put a lambda in as a function, but, you can use, use a,
use a function also, and just, just, then you can call them later. So you could just, dereference the,
um, or dereference, we don't call it like that. You look up the key, the element, in the dictionary,
and then actually just call it with parameters and it works. So, kind of a fun thing to do in
Python. he has a little bit of a, he said, as part of a vision script programming languages,
does that. interesting, but I mean, there's, there's a lot, there are times where you, you just
have lots of things that you're switching on and an easy way to do the switch is just to have a
dictionary lookup. So. Yeah, exactly. That's, it is pretty interesting. it's a traditionally,
it has been a way to do switch statements, which at the time it was pretty much all you had to work with.
Right. Since then we've had the match statement added to the language, right? Which is a little bit
better. So not switch, but match because it's this whole Arzor mechanism on top of just the switch
statement. But people used to traditionally say, okay, well, we'll just make a dictionary. And then
like your case is the key. And then what you do is the function that gets returned from that.
one thing that's really missing from that pattern, that dictionary dispatch pattern is that the default
case gets clunky looking, right? Like if, if none of the cases match, then what happens? Like you just
get none and exception, like none type is not callable or some weird thing like that. Right. Oh yeah, you do.
Yeah. So you could, you could upgrade it. You could upgrade it with a default dict where the default dict
returns the default case. Right. I, for a while, I don't remember when I added this, but I added
switch laying, which was fun and switch laying, uses context managers to simulate a switch with a default
case sort of thing. Yeah. Or, but Seth is pointing out, get, if you use get instead of a
dictionary lookup, you, you can have, give it a default to return. You can, but you got to give
it the default every, yeah, but you got to give it the default every time you use it, which is kind of
you can, but it is a little bit weird, right? Like that's why the default dict makes it a little
clear. Cause if you're going to use it more than one, I don't know. You use it more than once. It gets
janky. Right. So I, but so I've used this and I, I don't use, I don't put a fall through, but what I,
the reason is because it's all my code. It's all, I don't, it, it isn't something that's,
that's coming in from the outside world. It it's, and I have test cases around all paths. So,
right. So, you know, there's not going to be a missing case. Yeah. If you do an exception is
probably a good idea. It's not something you like, ask a user, which function would you like to call?
And then, you know, pass it through. it's a lead. Yeah. Don't do that. Anyway. I, I, oh,
I reason why I wanted to bring it up. Not is because I, not, I didn't want to bring this up because I wanted more
people to use a dictionary dispatch. you don't have to do that. What I brought it up for,
which is, it's still kind of cool to reference just to let people know you can do it. But,
this guy's got a blog role. How cool is that? when's the last time you seen a blog, a blog role?
Yes. Should we bring blog roles back? I don't know. Maybe, maybe, I don't know.
Anyway, that was when your blog was your little home on the internet. Yeah. Yeah. Yeah. How
interesting. Oh, there's no like, hit counter though. So, you know, Oh, does it have a
little dig? Like a little digging? This part is under construction digger. That'd be cool. No,
sorry, James, if you're listening, we're not dissing you. It's just fun. No, no, no. It's also,
it's nostalgia is what it is. Yeah, it is.
So anyway, all right, back, back to the, Seth Michael Larson show. Yeah. So
his, his article is very timely that he just put out, a little couple of weeks ago, but I'm
finally got around to featuring it now, given everything that's coming together called visualizing
the CPython release process. So it was awesome. He's the, Python security manager, security dev,
as opposed to Mike Fiedler, who is the pipe PI one. Both of these roles are somewhat new,
which are awesome. Right. This one is made possible by funding from open SSF alpha mega projects. So
very, very cool. And Michael or Seth is pointing out security developer in residence is the official
title. Yes. Right. Right there. and then we also have the developer in residence, which is
Lucas Lange. So anyway, they, they planned out or he went down and wrote out what it actually looks like
to release Python and boil boy. This is more than just, some build CI at GitHub to make sure that
the wheels or the binaries get built. So here's the process, see how close I can get this right. And
also, Seth is going to be on talk Python on Thursday in terms of live stream. And then a little
bit later to talk about, we'll talk about this and a bunch of other security things anyway. So start out,
freeze the release branch. And then the CPython upstream repo, goes along and the release
manager forks, the repo takes that feeds it into the release tool manually. All these things have,
there's a bunch of colors in this diagram. So each, each color, there's a legend like, the hand
ones are human tasks. The blue ones are release artifacts. Interesting from a security perspective.
Um, there's a source of risk is red and so on. All right. So the release tool goes along and get commit,
get tags things to, set the tag to version, you know, 3.12.0. Also it creates the source ball,
the tar balls from that. And where do we go now? We go over here to Azure pipelines for the windows
people, the Azure pipeline. There's a windows release manager, the Azure pipeline over there
builds out the windows embeddable packages of windows installers updates, new get windows store,
maybe even when get, I don't know about that. there's also an equivalent for the macOS release
manager who does the Mac build and Mac installer. And all of these things come back into testing artifacts
and creates the, they all get a GPG signature. And then we get everything signed and ready to go.
That gets dropped on python.org. Pretty cool. Huh? That is. Wow. Yeah. It's a lot. Last year,
they live streamed this and all the people involved were on zoom. I think it was, I'm not sure. It was
live stream to YouTube though. And you could actually see step by step. So, but I don't know how well people
really knew what was happening. Oh, you can be like, all right, we're on step five, everyone.
Let's go. Let's go. So I think, you know, if you're going to watch that live stream, if it exists,
I'm not sure it does. people in the audience, if they know it's going to be live streamed,
uh, shoot out a message. yeah. Okay. So it's too early to, I don't want to slow down to the release
this year, but maybe next year we could have this graph, but like animated with like little,
little things, what's going on. Yeah. Have like little, little, video cutouts of people on the
different sections and they're talking and yeah, it'd be fun. Why not? Why not? No, this is cool.
And then there's more about, there's like a more of a description below that Seth put together
as well as the sources of supply chain risk and examples of that happening outside of Python
primarily. so pretty cool. thanks for the, the visualization, Seth, this is great.
Yeah. This is cool. Nice. Yep. Over to you. no, wait, that's it for, I'll read for extras.
We are in extras. Do you want to do your extras first or? Yeah, sure. They're easy. I'm going to
be at pie Bay over in San Francisco, October 8th. So all I want to say is if you're around,
come say hi. Right. That's like primarily the reason that I go to conferences. I don't go to that
many talks or that many other things, but these kind of like get to know people in open spaces and so on.
So this is all one giant open space. This, pie Bay thing. Yeah. I went last year. It was fun.
Maybe we should just bounce back and forth and do every other. Yeah, absolutely. the
HTMX plus Django course is going really well. People are loving it. So if you want to do HTMX
with your Django code, it will make it so much better. Like you don't have to do front end frameworks
unless you really, really want to. so HTMX is awesome. This is how I use it with Django. Each
framework has its kind of own thing. The reason I bring this up is we're closing in at the end of
the early bird discount. So if you would think you're going to get it anyway, you've got until
September 29th until, the price goes up. A few more days. So check that out. Yeah. That's it for my
extras. Nice. I'll try to go through mine a little quickly. Anyway, of course the complete
pytest course, I up did just updated, part three is started. It's, not part three,
part two. I've started with chapter seven, testing strategy. So that's going along strong.
Um, I wanted to, mention some podcast names. so of course you're here with Python bytes,
that's us and my other one, a couple others, Python people, is, I've got a lot of great
interviews coming up. and then testing code is now Python tests. So you get the, just here,
we have Python bytes, Python people and Python tests. And then now talk Python to me is the odd man out.
So we have to get my, you got to change your name to Python talk. Python talk. Yeah. Python talk.
Yeah. Anyway, I could do that. I could change it. I can change whatever I want.
No, no, it's, it's working great. Don't change it. If it's not broken, don't fix it.
No, it's going, no, it's going pretty good. Speaking of broken, let's talk about the final thing,
a joke here. Okay. Maybe this has happened to you. Here's a, a woman developer trying to sleep,
but her mind is running and she's like, okay, mine, stop. I need to sleep. Leave me alone.
There's like a little conversation, brain woman in bed, right?
Says, Hey, are you sleeping? Yes. Now shut up. She says to her brain,
the brain says, I know how to fix the bug on line 255. Boom. Eyes wide open. No more sleep.
I can't sleep. We probably all been there, right? You're just like somewhere else. I know what it is.
I know what it is. Yeah. So that's one of the database index. No, it's one of the downsides,
but also one of the upsides of working being, having a setup for working from home so that you can just
run in and actually fix it and then go back to sleep. Right.
Or you can sleep at your desk. And then when this happens, you just wake back up and keep typing.
Okay. There we go. Yeah. Awesome. Well, I mean, I have a standing desk. Why not a,
like a sleeping desk though? Why? Yeah. Why? You know, it goes, they go from sitting to standing.
And it could just go one more level and you're like a lazy boy just drops you into like sleeping
position. Yeah. With a lazy boy. That'd be awesome.
White noise kicks in as it gets below a certain height. Yeah. Monitor goes up to the ceiling.
Exactly. Yeah. Be good. Anyway. All right. well, awesome podcast again, Michael. Yeah. Thank you.
Thank you as always. And thanks everyone for listening and some of you for attending.