WEBVTT

00:00:00.001 --> 00:00:04.460
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to

00:00:04.460 --> 00:00:11.900
your earbuds. This is episode 189, recorded July 2nd, 2020. I'm Michael Kennedy. And I am Brian

00:00:11.900 --> 00:00:16.880
Akin. And this episode is brought to you by us, our courses and our books and all those sorts of

00:00:16.880 --> 00:00:22.340
things. Tell you more about that later. Right now, let's talk about improving Python exceptions.

00:00:22.340 --> 00:00:26.860
Yeah, this came from Ram Ratcham. I'm probably getting his last name wrong.

00:00:27.200 --> 00:00:33.820
But this is a pretty interesting article. Actually, I had seen this in code. So exceptions are a big

00:00:33.820 --> 00:00:38.960
part of programming in Python, I think. Some people don't like to use them because they're kind of

00:00:38.960 --> 00:00:43.860
difficult in some languages, but it's pretty easy in Python. So let's say you've got a, you're dealing

00:00:43.860 --> 00:00:50.740
with an exception. You're inside of the accept part of a try accept block. And an exception happens. And

00:00:50.740 --> 00:00:56.800
if an exception is raised from an accept clause, which exception should be reported? And I really

00:00:56.800 --> 00:01:02.420
don't know what the mechanism was in Python 2. But there were changes made for Python 3 that are

00:01:02.420 --> 00:01:09.920
associated with PEP 3.1.3.4 and others that both of them will be reported. So you get both exceptions.

00:01:09.920 --> 00:01:15.140
But you get something like that. Often you get something that says during handling of the above

00:01:15.140 --> 00:01:20.280
exception, another exception occurred. Right. Which is super frustrating because it's not actually saying

00:01:20.280 --> 00:01:25.980
the error occurred trying to handle it. It's like, I'm trying to add more information to it or give you

00:01:25.980 --> 00:01:30.420
more detail or more specificity or something like that, right? Right. So what Rahm is pointing out is

00:01:30.420 --> 00:01:35.960
that if an exception is raised within an accept clause, it can be really one of two things. It can be

00:01:35.960 --> 00:01:42.620
something, I called some code that I didn't expect to have any exceptions and an exception happened there.

00:01:42.900 --> 00:01:50.140
And that's what kind of the default message sort of implies. But it might also be, and he has like this

00:01:50.140 --> 00:01:55.140
long block, I'm just going to read it. An exception was raised and we decided to replace it with a

00:01:55.140 --> 00:02:00.380
different exception that will make more sense to whoever called this code. Maybe the new exception will make

00:02:00.380 --> 00:02:05.340
more sense because we're giving it more helpful error message. Or maybe we're using an exception class

00:02:05.340 --> 00:02:10.500
that is more relevant to the problem domain. And whoever's calling our code could wrap the call with an

00:02:10.500 --> 00:02:17.440
accept clause that's tailored to this failure mode. So a long mouthful, but basically trying to be nice

00:02:17.440 --> 00:02:23.680
and raise a better exception or a better message or something. And in order to do that, all you have

00:02:23.680 --> 00:02:31.780
to do is just change one thing and it's the from E. So within your exception clause, you accept something

00:02:31.780 --> 00:02:38.680
as E or as, you know, any variable, but E is often used. You raise the other exception with a different

00:02:38.680 --> 00:02:45.500
message from E and that little from will get you a message within traceback. We'll have both exceptions.

00:02:45.500 --> 00:02:51.900
It'll say during the handling of the above exception, another exception occurred. Oh no, wait,

00:02:51.900 --> 00:02:55.200
no, it'll say that's what we had before. It'll say,

00:02:55.200 --> 00:02:59.780
That's a confusing one. Cause it looks like we tried to handle it, but we actually crashed again

00:02:59.780 --> 00:03:01.200
inside the handling of it. Right?

00:03:01.300 --> 00:03:07.760
Right. So the new thing, if you do the from E, it'll say the above exception was the direct cause of the

00:03:07.760 --> 00:03:15.620
following exception. So that's a little clearer, I think. So you have the one on the top caused the

00:03:15.620 --> 00:03:21.280
second one to happen. So you, you know that we're in the case of somebody's trying to wrap a, an exception

00:03:21.280 --> 00:03:27.540
with a friendlier exception, which is subtle. The reason why I kind of, I don't know, I just like it.

00:03:27.580 --> 00:03:34.280
Rom likes it. And, but he didn't see that no, that like nobody was using it. So he went even

00:03:34.280 --> 00:03:41.080
further and he went out and wrote a script that can look for probable places where that should be

00:03:41.080 --> 00:03:48.460
happening. And he did, he did pull requests to a set of tools, scipy, map plot, lib, pandas,

00:03:48.460 --> 00:03:54.700
py test, ipython, my py, pigments, and sphinx, which is like awesome that he just went out and

00:03:54.700 --> 00:03:58.820
did pull requests against all of those projects. Oh, that's really cool. The other thing he did was he

00:03:58.820 --> 00:04:08.800
wrote a new rule for pilot. And so w 0 7 0 7 raise, raise missing from, which is kind of weird, but, but

00:04:08.800 --> 00:04:14.940
basically pilot will now catch it. So if you use, the most recent, it's not released yet, but if you

00:04:14.940 --> 00:04:21.120
run pilot from GitHub, you can see that rule. But the next time they release pilot, it'll be in there.

00:04:21.120 --> 00:04:26.280
Yeah. This is neat. I like it. I think it's confusing the way it is now, if you don't do it

00:04:26.280 --> 00:04:31.760
the right way. And I also often get messages from students saying, Oh, I got this really bizarre

00:04:31.760 --> 00:04:37.340
error, like some, you know, some other thing. And the problem is buried in the other part of this

00:04:37.340 --> 00:04:43.260
whole story. Right. And it's, it's not clear what part they should be paying attention to. So I think

00:04:43.260 --> 00:04:47.140
this makes it more clear and it's nice. All right. Well, the next thing I want to talk about

00:04:47.140 --> 00:04:53.760
is publishing data science and other interactive stuff on the internet. Now there's a couple of

00:04:53.760 --> 00:04:59.900
ways you can do this. You could go to like Google collab and whatnot, but Tim Pogue sent over this

00:04:59.900 --> 00:05:09.000
new place where you basically custom built for this story and it's called data pain. So data pain is an

00:05:09.000 --> 00:05:14.720
open source framework, which makes it easy to turn scripts and notebooks into interactive reports.

00:05:14.920 --> 00:05:20.680
So you can export a Jupyter notebook as a report, but then it's just static. You can't interact with

00:05:20.680 --> 00:05:25.360
it. Or if you try to run it, then, you know, there's a bunch of code in there and there's all

00:05:25.360 --> 00:05:31.040
kinds of stuff that you probably don't want people to see. So data pain is a way to like create and host

00:05:31.040 --> 00:05:37.300
interactive HTML that runs against APIs and runs data and so on. It's pretty cool.

00:05:37.640 --> 00:05:43.480
You go in there and like use sliders to adjust what's happening in say a graph or filtering or

00:05:43.480 --> 00:05:47.700
things like that. That's neat. So this is one of those things that it's a paid service, but they

00:05:47.700 --> 00:05:53.180
have free accounts that you can do, right? Yes, exactly. So I'm not entirely sure the whole

00:05:53.180 --> 00:05:57.080
spectrum of what's going on. So it says it's an open source framework. So I think there's an API

00:05:57.080 --> 00:06:02.200
that you bring in to make this happen. And there might be a self-hosting story. They also have a

00:06:02.200 --> 00:06:06.900
platform for publishing it too. And on that platform, it's free for individuals, but I,

00:06:06.900 --> 00:06:13.340
I can't find a price anywhere, but it looks like they're going to eventually charge like for a team

00:06:13.340 --> 00:06:19.400
commercial corporate version. I don't really know what's going on with that anymore, but it's free

00:06:19.400 --> 00:06:24.540
for individuals and you can use their open source framework to generate these reports.

00:06:24.540 --> 00:06:28.960
Okay. And they also have the gallery there. So I was looking for, found it for a while.

00:06:29.100 --> 00:06:34.340
So obviously right at the top says open, open analysis gallery for looking at pictures.

00:06:34.340 --> 00:06:39.800
Exactly. Yeah. So the idea is that you can use like the tools that you already know and love. So

00:06:39.800 --> 00:06:45.800
you, you can use Jupyter or Colab or Airflow and you can build reports using their frameworks,

00:06:45.800 --> 00:06:50.680
using Markdown as well. And cool libraries that people probably are already using for visualization,

00:06:50.680 --> 00:06:55.240
like Altair, what I've been using for my visualizations lately. And then you can either

00:06:55.240 --> 00:07:00.700
export these as standalone HTML files, which is one option. That's the totally disconnected,

00:07:00.700 --> 00:07:05.760
just take the library. The other one is you can publish them to data pane for free where you can,

00:07:05.760 --> 00:07:10.240
people can share them and embed them. And there's probably this paid corporate thing that I don't have

00:07:10.240 --> 00:07:15.700
details on. Nice. Yeah. So you're going to add like forms to help filter and drive the report.

00:07:16.500 --> 00:07:23.260
You can have a talk to APIs. Also they have APIs that you can use to deploy your scripts to their

00:07:23.260 --> 00:07:28.520
server. And you can even have integrated set up with like GitHub actions or Airflow or standard CI,

00:07:28.520 --> 00:07:33.180
CD stuff to like update your reports on data pane.com. Yeah. So pretty cool. Like you said,

00:07:33.180 --> 00:07:37.260
there's a gallery. I'll link to the gallery at the end of the section. So these kinds of things,

00:07:37.260 --> 00:07:39.800
you just want to poke around the gallery and get a sense before you mess with it. Right.

00:07:39.840 --> 00:07:45.180
I like pictures. I do. We both like pictures. Now, before we go on to the next thing and we look at

00:07:45.180 --> 00:07:50.440
the ways in which pickle might make you sour, let's really talk about things that won't make you sour.

00:07:50.440 --> 00:07:55.060
Your pie test book. If people are interested in learning pie test, getting into testing and

00:07:55.060 --> 00:07:59.740
not just scratching the surface, but really deeply understanding pie test, they can check out your

00:07:59.740 --> 00:08:03.680
book, which we'll link to in the show notes. And if they would like to take some courses,

00:08:03.680 --> 00:08:09.520
we have a whole bunch of courses over at Talk Python. We're almost up to 200 hours of courses over there.

00:08:09.520 --> 00:08:14.000
That's a lot. Nice. It is a lot. But like I've said before, one of the things I like about it is

00:08:14.000 --> 00:08:18.140
you don't have to spend hours at a time. You can spend a few minutes and not lose your place.

00:08:18.140 --> 00:08:22.820
It's a nice way to set it up. Yeah. Thanks. On the pie test site, I wanted to reach out to people.

00:08:22.820 --> 00:08:29.680
I'm pretty available on Twitter or through the contact form on Talk Python, not Talk Python,

00:08:29.680 --> 00:08:37.300
Python bytes. However, I've had people try to email me at the contact form on Talk Python and Michael

00:08:37.300 --> 00:08:42.500
just send it to me nicely. So anyway, I want to like have people know, I'd like to know people,

00:08:42.500 --> 00:08:47.400
people, if they, if they want to learn how to test more, whether or not they've read the pie test book,

00:08:47.400 --> 00:08:52.760
what's stopping you? I don't know how to get in people's heads of why are they not testing more?

00:08:52.760 --> 00:08:56.120
So please reach out to me and let me know your questions. That'd be awesome.

00:08:56.120 --> 00:08:58.140
Yeah, absolutely. Now you want to make me sour?

00:08:58.140 --> 00:08:59.840
I love pickles. Do you like pickles?

00:08:59.840 --> 00:09:03.680
I'm coming around to them. I've used to really not like pickles, but I'm okay.

00:09:03.920 --> 00:09:07.820
Okay. I have a really fun pickle story to tell you, but it's like 10 minutes. It's better.

00:09:07.820 --> 00:09:12.080
Next time. But let's talk about Python's pickle. I kind of like it sometimes.

00:09:12.080 --> 00:09:17.840
No, it's one of the first things I learned about for saving data and stuff with is you can pickle

00:09:17.840 --> 00:09:21.960
stuff. So if you got whatever object, a bunch of objects or whatever in a collection,

00:09:21.960 --> 00:09:26.580
you can use pickle to serialize it somewhere. I think we've brought it up here on this podcast,

00:09:26.700 --> 00:09:32.300
but you will occasionally run into people saying, just be careful with pickle or never use pickle or

00:09:32.300 --> 00:09:39.080
something. And Ned Batchelder put together a post called pickles nine flaws where he says,

00:09:39.080 --> 00:09:44.460
it's not never use it, but you know, use pickle if you're okay with these flaws. So,

00:09:44.460 --> 00:09:48.860
and I like this list because I've heard some of these before, but never in one place.

00:09:48.980 --> 00:09:55.340
First off, it's insecure. So unless you really, I mean, if you're only pickling and unpickling your

00:09:55.340 --> 00:10:01.560
own data within your own program, and there's not a chance of having somebody else feed you bad

00:10:01.560 --> 00:10:07.380
pickles, then you're okay, but it's not secure. There's ways to have them and have malicious

00:10:07.380 --> 00:10:13.680
pickles be generated that can cause the unpickler to run random code, which is not what you want.

00:10:13.680 --> 00:10:19.940
And then he links to a more thorough article on the security. If you're worried about that old pickles,

00:10:19.940 --> 00:10:26.260
second one is old pickles look like old code. And the gist of it is, is it's, you can't really

00:10:26.260 --> 00:10:31.960
version this stuff. So if you change the way your objects look, your pickles aren't going to,

00:10:31.960 --> 00:10:36.560
it's not going to work right. Change your data structure and you got to pretty much throw all

00:10:36.560 --> 00:10:41.820
data away and start. Yeah. This one is really tricky because it takes the entire object graph.

00:10:41.820 --> 00:10:45.160
You say like, here, save this list. This list contains these things. These things contain

00:10:45.160 --> 00:10:49.440
pointers. So there's other things, it's going to save all of that stuff. And if the code that defines

00:10:49.440 --> 00:10:55.400
the fields of that change, I have your rename a field and you try to load it, you're done.

00:10:55.400 --> 00:10:59.560
It's not going to be able, it's like this blind binary blob that doesn't fit together anymore.

00:10:59.560 --> 00:11:04.880
There's not like a, well, let me adjust for this. It's just like, nope, nope. You can't no longer

00:11:04.880 --> 00:11:12.560
load that file. So it depends, but not being able to load your file at all or open it in a text editor,

00:11:12.560 --> 00:11:17.940
even that might be a bad place. Basically, if you're trying to save code between versions or save stuff

00:11:17.940 --> 00:11:23.840
between versions, it's not a good thing. There may be cases where you're just using it to serialize

00:11:23.840 --> 00:11:28.720
between a live app, a running application. And you're, you're not going to save that data anywhere.

00:11:28.720 --> 00:11:34.740
I think there was an interesting problem. I think it was Instagram that had this problem. Somebody

00:11:34.740 --> 00:11:40.560
that had done a big talk at PyCon, they were doing caching and something like Redis or something. And

00:11:40.560 --> 00:11:45.160
they were putting their pickles, they would pickle stuff, put it in the cache and they pull it out.

00:11:45.160 --> 00:11:49.420
And then they switched from like two to three and they could no longer read their cache. And it like

00:11:49.420 --> 00:11:53.120
took down the system or something. Yeah. Like something really, even really weird like that,

00:11:53.120 --> 00:11:56.960
like deploying a new version of the site. Yeah. Yeah. I'll read through the whole list. We can pick

00:11:56.960 --> 00:12:02.180
out a few. They're implicit. So it serializes everything, even if you don't want it to.

00:12:02.180 --> 00:12:08.140
Oh, that's the over serializes. The implicit part is it serializes things as class objects.

00:12:08.140 --> 00:12:15.320
And even if that's not really what you'd want, like his example is date time, you really wouldn't want

00:12:15.320 --> 00:12:19.640
to serialize it as a date time object. You'd want to serialize it as a string or something.

00:12:19.640 --> 00:12:26.420
The init isn't called. So normally your classes, the init gets called, but during unpickling,

00:12:26.420 --> 00:12:31.520
it just creates this object without calling init. So if there's any side effects that you need to have

00:12:31.520 --> 00:12:36.620
happen, that ain't going to happen. It's Python only. You can't convert it between different languages.

00:12:36.620 --> 00:12:42.320
It's unreadable. You mentioned it's binary. So if anything goes wrong, good luck with debugging it.

00:12:42.320 --> 00:12:47.200
It appears to pickle your code, but it really doesn't. So if you've got a list of functions and classes

00:12:47.200 --> 00:12:52.120
and objects, those will be in there, but it's just names of stuff. And then when,

00:12:52.120 --> 00:12:59.660
when you unpickle it, it creates those objects without calling init, it's slow. And so the binary

00:12:59.660 --> 00:13:05.160
part gets me, but basically these are all the things that are wrong with it, but there's some

00:13:05.160 --> 00:13:09.340
ways to get around it. And a lot of people will say, well, there's ways to get around it. And,

00:13:09.700 --> 00:13:15.120
Ned's comment is if you're going through some of the code to work around the problems with pickle,

00:13:15.120 --> 00:13:20.100
then just why are you using pickle? There's other things out there. And my favorite alternative is

00:13:20.100 --> 00:13:28.240
just Jason. So Jason mostly works most of the time and you can read it. So you can look at what's wrong

00:13:28.240 --> 00:13:33.640
and go, Oh, I see why that didn't work because I was putting this garbage in there or whatever,

00:13:33.640 --> 00:13:37.400
or I haven't tried these others. So there's a other suggestions like marshmallow,

00:13:37.400 --> 00:13:43.320
catters, protocol buffers. I haven't used those before, but the, what was I going to bring up?

00:13:43.320 --> 00:13:48.160
You brought up something about being binary and that's one of the parts that gets me as a

00:13:48.160 --> 00:13:55.540
serializer that goes to binary. That makes sense if it's really fast, but using a slow serializer to

00:13:55.540 --> 00:14:03.440
slow and binary. Come on. Yeah. One of the things that the over serializing that I found is interesting is

00:14:03.440 --> 00:14:08.760
caching is something we do for like a long, hard computations or something, or just to save some

00:14:08.760 --> 00:14:14.060
computation, you cache the result, that stuff will get saved in your pickle also. And that's

00:14:14.060 --> 00:14:19.300
surprising. So it's just weird. Yeah. So thanks Ned. Yeah. It's a cool article. You know, the one

00:14:19.300 --> 00:14:24.980
place that pickle kind of makes sense to me is if I'm doing like a really quick prototype and what I

00:14:24.980 --> 00:14:29.860
would need to save would be fairly complicated. I'm just like, you know what? I just want to save this.

00:14:30.500 --> 00:14:34.460
And if I really invest and I like what we built here, we're going to go and rewrite this with a

00:14:34.460 --> 00:14:39.980
proper serialization data saving story. Yeah. I could see that. I, all right, just pickle it. Now I

00:14:39.980 --> 00:14:44.120
don't really often do that, that off a very light, you know, it's not very common, but I would certainly

00:14:44.120 --> 00:14:49.360
consider like, I just need to save this complicated data structure and I don't want really know if I

00:14:49.360 --> 00:14:53.280
even need this forever, but I'm just going to do it for now. I might consider pickling, but in general,

00:14:53.280 --> 00:14:57.720
it's not super awesome. And also the malicious bits makes you, you know, you got to be careful.

00:14:57.720 --> 00:15:02.580
So the reason why you can't grab Jason right away is because there's some objects that are

00:15:02.580 --> 00:15:06.980
not serializable, right? Yes, exactly. And some things that are simple, like date times, like if

00:15:06.980 --> 00:15:12.520
you had a really complicated, some structure that had like say date times or other objects in there,

00:15:12.520 --> 00:15:16.520
you can't just dump the whole thing to Jason. Right. So if you, if you were just in a hurry,

00:15:16.520 --> 00:15:19.720
you're like, I'm just really trying to spend 30 minutes to figure this out, but I just need to

00:15:19.720 --> 00:15:24.380
save this and then load it. And like, then maybe pickling makes sense. But the fact that you,

00:15:24.380 --> 00:15:28.820
you could never be, it's very possible you upgrade Python, you can never load it again

00:15:28.820 --> 00:15:33.280
or things like that. You can't look at it. Like that makes me never want to invest in this as like a

00:15:33.280 --> 00:15:38.740
long-term option. Yeah. The other thing I thought might be a reasonable thing is, I'd like to hear

00:15:38.740 --> 00:15:44.260
other people's thoughts on what reasonable uses for pickle are, but like, in memory stuff. So you're,

00:15:44.260 --> 00:15:49.260
you're serializing it just to get it from one part of your system to another or something.

00:15:49.260 --> 00:15:55.280
yeah. Yeah. Yeah. Like a super deep copy sort of thing might make sense potentially. Right.

00:15:55.280 --> 00:16:01.880
yeah. Speaking of it might change because you get a new version of Python that is now going to be more

00:16:01.880 --> 00:16:09.140
common. Yeah. Yeah. So Lucas Lenga, he's been in charge of releasing a release management of Python

00:16:09.140 --> 00:16:19.580
recently and he has gotten Pep 602 accepted and Pep 602 says we're switching from a 17 to 18 month

00:16:19.580 --> 00:16:25.840
release cycle to a yearly release cycle. Yay. That makes sense. Yeah. Remember we were talking

00:16:25.840 --> 00:16:31.300
about something that got into Python three nine and we were looking at the conversation

00:16:31.300 --> 00:16:36.840
on the dev channel and it was like, I really, really tried. I submitted this before the deadline,

00:16:36.840 --> 00:16:43.740
but you guys weren't able to like review the PR before the window closed for three eight. So because

00:16:43.740 --> 00:16:49.040
of that, like that feature missed by a couple of weeks and it was a year and a half before it could

00:16:49.040 --> 00:16:54.500
actually get accepted. Right. It was like really long. So on one hand, this, this is to shorten that

00:16:54.500 --> 00:17:00.580
cycle. The other thing is on a given year, when will Python come out? I don't know. Is it an even year

00:17:00.580 --> 00:17:05.200
or an odd year? Like that's just a weird way to think of things, right? We have conferences yearly

00:17:05.200 --> 00:17:12.940
in theory, things like that. Right. But for Python, it had been on this 18 month sort of alternating cycle

00:17:12.940 --> 00:17:22.440
this way they can schedule it. So that things like the feature freeze or beta stage happens right after

00:17:22.440 --> 00:17:29.620
PyCon. So the sprints can always focus on getting that last bit into CPython at PyCon and what, and it's

00:17:29.620 --> 00:17:33.520
much more predictable. So I think that'll be nice. Yeah. And there's other stuff in life like,

00:17:33.520 --> 00:17:38.320
you know, holidays and things like that, that you can just sort of figure out when a good time is for

00:17:38.320 --> 00:17:44.660
the whole schedule and then just do that every year. Absolutely. Absolutely. So let's see. There's a

00:17:44.660 --> 00:17:54.560
little bit of interesting detail. It says the PEP proposes that Python 3.whatever be developed around,

00:17:54.560 --> 00:18:01.100
I think it's a seven over 17 months across a 17 month period, which doesn't sound annual, does it?

00:18:01.100 --> 00:18:08.500
No. So the way it works is the first five months will overlap with the previous versions beta period.

00:18:08.980 --> 00:18:15.540
And then there's seven months spent on the alpha release and then three months on beta releases.

00:18:15.540 --> 00:18:20.120
And then finally two months on release candidates. So there's the way it's going to work instead of like,

00:18:20.120 --> 00:18:25.240
we're now on 3.8. Now we're all focusing on 3.9 that 3.8 is out. There's like an overlap. So

00:18:25.240 --> 00:18:32.100
basically as soon as the features freeze on the previous, on the what's coming out, right? So

00:18:32.100 --> 00:18:38.740
like right now 3.9 is coming out. So as soon as it hit feature freeze, 3.10 would start, right? So

00:18:38.740 --> 00:18:43.220
there's like this overlap as the version that's coming out is getting stabilized and finalized new

00:18:43.220 --> 00:18:47.600
features and developments already happening on the other one. And the way with that overlap working,

00:18:47.600 --> 00:18:52.300
it's going to result in a new version every 12 months. There'll be like a five month period of where

00:18:52.300 --> 00:18:56.160
there's like new features go to the new one and stabilization to the old one. And this is kind

00:18:56.160 --> 00:19:00.340
of how commercial software is done anyway. Yeah. Yeah. You never like, no one touches the new one

00:19:00.340 --> 00:19:05.560
until we've like shifted the gold version. Like now, like some people are fixing stuff that they need

00:19:05.560 --> 00:19:09.740
to fix. And some people are putting the new features. So in terms of advantages, they call out,

00:19:09.740 --> 00:19:15.400
makes the releases smaller. So doubling the cadence doesn't double their available development

00:19:15.400 --> 00:19:20.940
resources and so on. And consecutive releases are going to be smaller in terms of features. So that's good.

00:19:20.940 --> 00:19:27.080
It puts features and bug fixes in the hands of users sooner, right? Six months sooner. It creates

00:19:27.080 --> 00:19:33.560
a more gradual upgrade path, right? Instead of adopting 18 months at a time, you can adopt 12 months

00:19:33.560 --> 00:19:38.380
at a time. Like you could be, if you're saying like, we're always going to be one version back of what

00:19:38.380 --> 00:19:42.980
just got released on the Python, right? So if you're saying we're going to run on three, seven in today's

00:19:42.980 --> 00:19:47.840
world, right? That's not an 18 month gap. That's a 12 month gap. So that's good. You're a little less

00:19:47.840 --> 00:19:53.760
far behind if you're on the laggard side of things. The predictable calendar. So the final release is

00:19:53.760 --> 00:19:58.920
always going to be in October after the annual core sprint. And the beta phase always starts in May.

00:19:58.920 --> 00:20:04.640
So after the PyCon US sprint. So there's like a nice lineup for that as well.

00:20:04.640 --> 00:20:09.740
Also, my prediction is that people won't be doing the two version thing. They'll actually do three.

00:20:09.740 --> 00:20:10.020
Yeah.

00:20:10.100 --> 00:20:15.060
I recommend everybody do this anyway. So let's say like right now, if you've got a project on Python,

00:20:15.060 --> 00:20:19.860
you should make sure that it works on three, seven and three, eight, of course, but also three,

00:20:19.860 --> 00:20:25.640
nine's around. So tested on three, nine also. And then when, when three, nine is the official one,

00:20:25.640 --> 00:20:30.020
maybe you keep three, seven, but if you don't want to, you're at least doing,

00:20:30.020 --> 00:20:34.540
making sure you're compatible with the next one, the current one and the last one. So

00:20:34.540 --> 00:20:36.380
it'll make more sense.

00:20:36.380 --> 00:20:41.320
Absolutely. Very good. Now we spent a lot of last episode on Git, right?

00:20:41.320 --> 00:20:47.800
Yeah. Well, episode 187, we talked about, Oh Shit, Git from a zine from Julie Evans. And I,

00:20:47.800 --> 00:20:52.100
I mentioned that I was concerned about, I wanted to buy this for my team, but I was,

00:20:52.100 --> 00:20:58.300
I didn't know if HR would like the naming of it. And John Place reached out, one of our listeners and

00:20:58.300 --> 00:21:03.320
said, you know, there's a non-swearing version. He actually sent us a ton of great Git information.

00:21:03.920 --> 00:21:07.300
So the same little magazine, you can get it as Dang It, Git.

00:21:07.300 --> 00:21:08.560
Ah, shucks, Git.

00:21:08.560 --> 00:21:09.540
Ah, shucks, Git.

00:21:09.540 --> 00:21:17.920
God darn it, Git. All of those would be good, but it's Dang It, Git. And then also when I was

00:21:17.920 --> 00:21:23.220
looking around these, there's also, these were zines that you can buy, but these were inspired by two

00:21:23.220 --> 00:21:31.820
websites that were put together by Katie Siler Miller, DangItGit.com and OhShitGit.com are,

00:21:32.340 --> 00:21:38.520
there's actually really cool. These are free websites that have kind of the idea of something

00:21:38.520 --> 00:21:45.020
went wrong. How do I fix it? And then every single one of the topics is clickable and linkable. And I

00:21:45.020 --> 00:21:48.400
didn't understand the clicks at first. I'm like, Oh, these are links. Do they go to articles?

00:21:48.400 --> 00:21:53.640
Oh, it just takes me right to where I already was. I don't understand this. Why would I do this?

00:21:54.020 --> 00:21:58.720
Well, it's so that they're anchors so that you can click on it and get the URL and send it to

00:21:58.720 --> 00:22:03.400
somebody. So if somebody asks you a question and the answer's here, you can send them the link and

00:22:03.400 --> 00:22:10.260
say, here's how to fix it. And then next time they can fix it themselves. So these are neat things in

00:22:10.260 --> 00:22:15.920
the community. And then also this, okay. Do you see the link for Git cheat sheet? Have you looked at

00:22:15.920 --> 00:22:20.240
this yet? I'm looking at it now. I thought this was going to be a Git PDF, like a PDF or something

00:22:20.240 --> 00:22:26.520
with a bunch of commands, but this is an incredible resource. The Git cheat sheet is an interactive

00:22:26.520 --> 00:22:34.180
single page website. That's just beautiful to look at for one, but it's got five columns. I'm going to

00:22:34.180 --> 00:22:40.080
pull it up. Also, it's got five columns, the stash workplace index, local repository, and upstream

00:22:40.080 --> 00:22:47.740
repository. And you just, when you hover over it or click on the different columns, it shows you all

00:22:47.740 --> 00:22:54.920
of the different Git commands that affect that. So if you click on the local repo, for instance, it'll

00:22:54.920 --> 00:23:01.140
show you how to get information from, you know, diff, how do you compare between the workspace and the

00:23:01.140 --> 00:23:08.120
local repo, what reset does, switch, rebase, cherry picking, and all sorts of stuff. And then different

00:23:08.120 --> 00:23:13.860
commands that go between the index and the local repo and the local repo and the upstream one with

00:23:13.860 --> 00:23:19.700
pushes and stuff. But it has this nice visual of where your stuff is and how do you get it back and

00:23:19.700 --> 00:23:24.720
forth. And then you hover over, if you hover over any of the commands, it shows you the information on

00:23:24.720 --> 00:23:30.040
the bottom. This is just great. I'm going to share, I'm going to share this with my team for everybody

00:23:30.040 --> 00:23:35.140
that's kind of, because one of the things that, that takes a while to get your head around with Git is

00:23:35.140 --> 00:23:41.900
this idea of what is the workspace and the index and the local repo and stuff. So having a visual

00:23:41.900 --> 00:23:46.560
of what commands affect which part of Git, it's pretty, pretty darn cool.

00:23:46.560 --> 00:23:46.920
Yeah.

00:23:46.980 --> 00:23:52.000
The last thing I wanted to share was, this is a one pager that you could print out. It's a Git

00:23:52.000 --> 00:23:59.300
pretty that is kind of like the dang it kid and oh shit get offerings, where it's a single page PNG

00:23:59.300 --> 00:24:04.800
flow chart that starts with, so you have a mess on your hands. And then it asks you a bunch of

00:24:04.800 --> 00:24:10.300
questions of funneling it to like what commands might fix it. And I don't know if I use this much,

00:24:10.300 --> 00:24:14.960
but I totally want to print this out and put it on my cubicle wall because it's kind of entertaining.

00:24:15.160 --> 00:24:16.380
Yeah, this is really cool. I like it.

00:24:16.380 --> 00:24:17.380
More Git resources.

00:24:17.380 --> 00:24:21.640
These are a bunch of great, yeah, a lot of, a lot of bunch of Git resources. All right,

00:24:21.640 --> 00:24:25.340
I'm going to close this, our main items out, Brian, with a simple one. Okay.

00:24:25.340 --> 00:24:25.780
Okay.

00:24:25.900 --> 00:24:33.040
So there's a new PEP around strip, basically. That's the short version before I tell you the

00:24:33.040 --> 00:24:40.540
long version. Okay. So if I have a string and the string is Saturday is the first, like so Saturday

00:24:40.540 --> 00:24:49.280
is the number one ST. And suppose for whatever reason, I'm not sure it's a really normal use case,

00:24:49.280 --> 00:24:58.160
but for whatever reason, I want to get the ST off of the end here. And so I might say dot strip ST.

00:24:58.160 --> 00:24:59.660
What comes out of there?

00:24:59.660 --> 00:25:02.580
Yeah, that's interesting.

00:25:02.800 --> 00:25:07.960
So what I thought was when I first encountered the strip function, I would pass it a string and that

00:25:07.960 --> 00:25:13.620
string would be taken away from the string that I was stripping it from. So like, if I say dot strip ST,

00:25:13.620 --> 00:25:18.480
it's going to take the ST off the end. But what it really means is take away all the S's and take

00:25:18.480 --> 00:25:24.500
away all the T's until you hit something else. So it would be Saturday is the one, right? It would take

00:25:24.500 --> 00:25:30.100
the S off the front, even though it's not ST, it's just S, right? Yeah. Yeah. I mean, I guess the idea

00:25:30.100 --> 00:25:34.100
is you give it a space, a tab and a backslash in and a backslash R and you say, take that away.

00:25:34.100 --> 00:25:39.600
And that destroys the white space, right? That's probably the foundation, right? But you give it

00:25:39.600 --> 00:25:43.640
a string, it doesn't take the string away. It turns it into a bunch of characters and it just takes the

00:25:43.640 --> 00:25:49.720
characters away. But what if you wanted to take away the ST? Well, you've got to write a bunch of code

00:25:49.720 --> 00:25:55.720
that goes and finds the ST and sees if it's at the end and then take it away. Or you wait a little

00:25:55.720 --> 00:26:03.200
while and use a new function that's going to be in 3.9 called remove prefix or remove suffix. So

00:26:03.200 --> 00:26:10.240
Dennis Sweeney has got a PEP accepted to add these two functions that are actually probably what you

00:26:10.240 --> 00:26:14.980
first thought that strip would do. Given a string, it's going to take it that string off of the ends.

00:26:14.980 --> 00:26:19.420
Okay. Not a big deal, but I suspect that there's probably people out there that type

00:26:19.420 --> 00:26:25.260
more than one character into strip and expect it to be treated as a substring when it's not. And so

00:26:25.260 --> 00:26:28.280
there's going to be in 3.9 two functions that do that.

00:26:28.280 --> 00:26:35.320
Yeah. I mean, I totally, because I get the need to have like a set of things. If you want to pass

00:26:35.320 --> 00:26:40.760
it in like a space and a tab and a new line, there's a bunch of things you want to strip off the end.

00:26:40.760 --> 00:26:45.160
Well, there's easier ways to strip the white space, but like, let's say there's other like random

00:26:45.160 --> 00:27:01.020
stuff that might appear at the end. Yeah. Stripping that, but having it be character. I was totally surprised by that. I didn't believe you. I just typed it in because I'm like, well, what about the S and is, but no, it just, the strip takes those. It's a set of characters that are only at the end.

00:27:01.020 --> 00:27:17.980
Yeah. It takes the S off Saturday and the ST off of first, but it leaves the other ones alone. Yeah. Yeah. Yeah. So replace doesn't, there's not, there was not really a great way in Python to do that without writing your own function that checks that those are only on the ends and then takes them away. And so now remove prefix and remove suffix.

00:27:17.980 --> 00:27:35.020
Nice. Cool. Nice. And just to finally, this will be applied to all the string like things in Python. So Unicode str, binary bytes, byte arrays, objects, and collections dot user string. So not just against str, but it takes all these other things that are string.

00:27:35.020 --> 00:27:37.720
Oh, nice. Stringish. Is that a technical term?

00:27:38.780 --> 00:27:47.520
That's, I think if we get the PEP accepted, it'll be technical. Yeah. Okay. No. Yeah. All right. So that's it for our main items. What else you got?

00:27:47.520 --> 00:27:51.260
I've just been working a lot. So I got nothing. How about you?

00:27:51.260 --> 00:28:04.940
Got nothing. Well, actually a couple of things going on. So Manning, the book publisher, they are going to have a Python conference in a couple of days. I'm pulling up really quick to see exactly what day that is.

00:28:04.940 --> 00:28:12.700
I think, actually, I do know what day it is. I think it's the 17th. Okay. I think it's the 17th of July. Anyway, we're going to be there.

00:28:12.700 --> 00:28:13.100
Yeah.

00:28:13.100 --> 00:28:27.620
Not the 17th. It's the 14th. It's the 14th. The 14th of July. So we're going to be doing a live Python bytes at the Manning conference. And I'll put a link to it in the show notes so you guys can sign up. So you want to see us do a live event?

00:28:27.620 --> 00:28:34.740
We've done that at PyCon. We've done that at some other events. And it'll be fun to do it virtually, which is basically all we get for our conferences, right?

00:28:34.740 --> 00:28:38.320
By live, you mean like in real time, but like online?

00:28:38.320 --> 00:28:40.320
Right. With audience questions and stuff like that.

00:28:40.320 --> 00:28:40.700
Oh, okay.

00:28:40.780 --> 00:28:55.780
So that'll be fun. Also, I did a talk on 10 techniques for web developers with a little bit of a focus on Pyramid, but more generally just for web developers, tips and tricks and tools and whatnot at the Python virtual conference.

00:28:55.780 --> 00:29:02.440
That was last month. Well, maybe the big, yeah, last month for sure in June. So the recording for that is out and I'll put a link to that as well.

00:29:02.660 --> 00:29:19.320
We also have a humble bundle running right now. It's probably when this episode comes out, got another week or so. So there we've got a couple of courses for me, but tons of stuff, stuff from Matt Harrison and stuff from real Python and we've been learner and on and on great long list.

00:29:19.320 --> 00:29:25.740
There's like $1,400 worth of Python content and get it for 25 bucks. So that's going like crazy right now.

00:29:25.740 --> 00:29:33.940
So if you're thinking about maybe taking one of the courses for either for me or one of these other guys, check it out. It's pretty much as good of a deal as you're going to get on those.

00:29:33.940 --> 00:29:37.860
And then lastly, lastly, I'll be sick.

00:29:37.860 --> 00:29:41.040
Pednecker. Hopefully I got your name close to right there.

00:29:41.040 --> 00:29:49.900
Actually built something really cool for us. So at Python by side of him and talk Python dot FM, we have a search API and click on the little search box in the top right.

00:29:49.900 --> 00:29:57.100
And there's like a link to a JSON API you can use. So he did, of course, what you should do when you find an API and use it.

00:29:57.100 --> 00:30:06.580
He wrote two Telegram bots and you can just speak to the Telegram bot and you can either install the talk Python one or the Python bytes Telegram bot.

00:30:06.580 --> 00:30:13.620
If you just text or speak to it in Telegram, it'll search talk Python and give you relevant responses about stuff we've covered.

00:30:13.620 --> 00:30:14.980
What? That's cool.

00:30:14.980 --> 00:30:16.900
Isn't that cool? Yeah, it's super, super cool.

00:30:17.040 --> 00:30:21.100
So I'll put the links to get those those Telegram bots for you if you want.

00:30:21.100 --> 00:30:22.540
Nice. All right. You ready for a joke?

00:30:22.540 --> 00:30:25.300
I am. All right. This one comes from Karen Chi.

00:30:25.300 --> 00:30:27.120
I don't think she submitted it to us.

00:30:27.120 --> 00:30:30.560
I think we just found it on Twitter, but here's a quick adaptation.

00:30:30.560 --> 00:30:32.880
It's not exactly what she said. I expanded a little.

00:30:32.880 --> 00:30:35.580
She did it on Twitter, so it had to fit within a couple of characters.

00:30:35.580 --> 00:30:38.420
So it's a conversation.

00:30:38.420 --> 00:30:40.160
And Brian, let's just have it together.

00:30:40.160 --> 00:30:40.840
OK, OK.

00:30:40.840 --> 00:30:41.840
Who do you want me to be?

00:30:41.840 --> 00:30:43.180
Oh, I'll be you.

00:30:43.180 --> 00:30:45.560
No, I'll be me.

00:30:45.560 --> 00:30:46.240
Wait.

00:30:46.420 --> 00:30:46.560
OK.

00:30:46.560 --> 00:30:51.440
Yeah. I'll start off. How's that? Because it's very confusing the way I phrase that.

00:30:51.440 --> 00:30:56.260
All right. Hey, a famous engineer inventor is coming over tonight for dinner. You want to join us?

00:30:56.260 --> 00:30:57.060
Sure. Who is it?

00:30:57.060 --> 00:30:58.840
Oh, his name is Rube Goldberg.

00:30:58.840 --> 00:31:06.000
That name rings a bell, which sets off a trap under the that undoes a buckle and releases a ball that rolls down a pipe.

00:31:06.000 --> 00:31:07.160
And yeah.

00:31:08.400 --> 00:31:09.980
And on and on and on and on and on and on.

00:31:09.980 --> 00:31:13.020
All right. Well, that's it. Rube Goldberg. I love those things.

00:31:13.020 --> 00:31:15.420
I should probably go check the Internet for some really funny ones.

00:31:15.580 --> 00:31:26.020
And with all the coronavirus stuff, there's actually some awesome Rube Goldbergs that people are putting together on YouTube lately because people are at home and they have lots of time on their hands and their kids are home.

00:31:26.020 --> 00:31:32.480
Absolutely. Absolutely. All right. Well, I'm definitely going to go check YouTube now.

00:31:32.560 --> 00:31:33.120
Okay. Bye.

00:31:33.120 --> 00:31:34.660
All right. See you, Brian. Thanks.

00:31:34.660 --> 00:31:40.260
Follow the show on Twitter via at Python Bytes. That's Python Bytes as in B-Y-T-E-S.

00:31:40.260 --> 00:31:43.500
And get the full show notes at pythonbytes.fm.

00:31:43.500 --> 00:31:47.720
If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

00:31:47.720 --> 00:31:50.400
We're always on the lookout for sharing something cool.

00:31:50.400 --> 00:31:53.520
On behalf of myself and Brian Okken, this is Michael Kennedy.

00:31:53.520 --> 00:31:56.940
Thank you for listening and sharing this podcast with your friends and colleagues.

