Transcript #188: Will there be a "switch" in Python the language?
Return to episode page view on github00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
00:05 This is episode 188, recorded June 24th, 2020. I'm Brian Okken.
00:13 And I'm Michael Kennedy.
00:14 And this episode is brought to you by us, Talk Python Training and Brian's fabulous pytest book.
00:20 Brian, can you believe 188 contiguous episodes?
00:23 I cannot. The number keeps going up. I guess that's what numbers do.
00:28 I guess so. It's awesome. I'm glad we're still doing it. It's fun.
00:31 What you got for us to start with?
00:32 Well, you may have heard me talk about async. And actually, I didn't cover it on purpose.
00:38 There's sort of a controversial async article going around. Don't really want to talk about it at the moment, unless I have to.
00:45 But I do want to talk about my favorite async thing, which is unsync. U-N-S-Y-N-C. Unsync.
00:52 Okay.
00:53 I feel like the Python core developers should look at this and say, you know what?
00:57 We massively overcomplicated all the asynchronous parallel capabilities of Python.
01:04 Let's create a unifying API that is the one simple way that you can do things.
01:10 And if you need to dig into the details of the other ones, that would be great.
01:13 They haven't done that yet.
01:14 I mean, async it away.
01:16 The keywords are great.
01:17 But if you want to, say, work with like a thread and some asyncio thing, the way you do it is like totally destroy and unrelated.
01:25 So this unsync library is like a unification library on top of threading, multiprocessing, and async and await.
01:33 So I've talked about that a bunch of times, and it's sweet.
01:35 I'd love to see Python just adopt something very similar to that API internally.
01:41 Anyway, there's a cool article called Making a Trading Bot Asynchronous Using Python's Unsync Library by Matt Godston.
01:49 Oh, nice.
01:49 Yeah, it's cool.
01:50 It just walks you through a somewhat realistic example of creating something that does freighting.
01:56 And in order to do it, it has to go and, you know, it talks to different web services and some databases and whatnot.
02:03 Now, all these are simulated with a function call to a time.sleep call, right?
02:09 One of the things you'll see a lot of people when they do like these performance analyses and stuff is they'll have some async code and it's hitting up against some other thing.
02:20 And that other thing has a performance limit that is like near what it can handle anyway.
02:26 And so you can't get a big boost out of it.
02:28 So this kind of like puts that to the side and says like we're not going to actually talk to another thing because maybe that thing is slower than we can handle or who knows.
02:36 We're just going to go and simulate slowness by sleeping, right?
02:41 So it actually walks you through some different ways of doing things.
02:44 It has a synchronous version and the async and await version using unsync.
02:50 I don't know if there's intermediate.
02:51 I can't remember if there's intermediate versions in this tutorial about having just a pure threaded version, right?
02:57 But it's mostly about taking the synchronous version and making it unsync.
03:00 So it's nice because it's a somewhat realistic example.
03:04 It's not as much of a realistic example as some of the scenarios.
03:09 It's not as ideal of an example as some of the other scenarios.
03:12 Like for example, if I need to web scrape a hundred different websites, right?
03:16 You can do that a hundred times faster by just like kicking them all off and getting it back and not really waiting because all the work is happening distributed elsewhere.
03:24 But it's still a pretty realistic example doing some different things.
03:27 It would be fun to hear it talk about scalability more like how much it's like we've got a couple.
03:34 I think it's doing three things.
03:35 It's like, look, we could do these three things quicker.
03:36 But, you know, like what is the limit?
03:38 Like how far can you push it?
03:39 Because I think you could push it quite far actually with what they're doing.
03:43 It's just hard to know when if sleeps are representative as well.
03:47 Yeah.
03:47 It is hard to know if like a sleep is representative.
03:49 Basically, if it's like a truly external system that has infinite scale, right?
03:55 Some cloud service, then a sleep is probably pretty representative.
03:58 Like whatever you're doing is not going to affect it.
04:00 But if it's say like a database, right?
04:03 If I'm doing 10 requests against the database versus one, maybe the database can't handle it.
04:08 And it slows down to what like two or three queries at a time would be like.
04:11 There's things like that, right?
04:12 Where it hits a limit.
04:13 But if the thing you're talking to totally scales and sometimes it does, sometimes it doesn't.
04:18 One thing that I think is missing from this is it doesn't actually use async methods.
04:25 It just has regular methods.
04:27 So this is really an interesting thing, right?
04:29 So it's like, okay, we're going to put unsync on it.
04:31 Here's some regular functions and we put the unsync decorator, which turns them into these things that are awaitable and parallel and so on.
04:38 And what you really probably want to do is actually leverage async and await, create, you know, def async methods, use, you know, await asyncio sleep and all that kind of stuff.
04:48 So it didn't actually fully transition them to leveraging asyncio.
04:53 But what I think is interesting about that is it still got much better with unsync.
04:57 And what's cool is like it said, okay, well, these are not async methods.
05:00 So we're going to have to use threads, but let's just fire them off with threads anyway.
05:03 And because the time.sync releases the gill, just like a network call would, it still kind of works.
05:09 So it's kind of neat that like it wasn't fully converted over, but unsync still made it better in the same way that you would expect.
05:16 Interesting.
05:16 Yeah.
05:17 Yeah.
05:17 Yeah.
05:17 So anyway, a cool example of someone talking about unsync was not me.
05:22 Except for right now, reviewing it.
05:25 There's a lot of cool stuff in there, kind of like a fruit salad, would you say?
05:29 Yeah.
05:30 Just a lot of stuff to take and it's sweet and people generally enjoy it.
05:33 Oh man, I shouldn't have picked this story right before lunch also, because I'm kind of hungry.
05:37 I know.
05:38 I know.
05:39 It's good.
05:40 So tell us about this.
05:41 I was going to put this as an extra thing, but I put it as one of my topics because it's actually pretty darn cool.
05:46 So this, on Twitter, Lacey Henschel just asked the question of like, there was this scrum estimation tool with fruit.
05:54 Does anybody remember it?
05:56 And Kathleen Jones replied and said, is this it?
06:00 Essentially.
06:01 And it was.
06:01 And so we're linking to this article.
06:04 It's called the Fruit Salad Scrum Estimation Scale.
06:08 And, you know, task planning and scrum estimation is a, you know, it's a kind of an art form and a science together.
06:16 It takes a while to get things right.
06:18 So maybe just really, really super quickly tell people, what is this scrum estimation about?
06:23 Oh, okay.
06:24 Maybe scientists and they're like, we don't do that in our biology lab.
06:27 Oh, that's true.
06:28 Lots of teams have picked up scrum or sort of a variant of scrum, which is a way to plan what tasks, what things that people are going to work on.
06:39 And the things that people work on, we kind of want to, you know, have a, like a size for them.
06:45 And instead of doing like, oh, it's a one day task or a two day task or a five day task, or some people just use small, medium, large.
06:52 T-shirt sizes are popular.
06:53 And then also, for some reason, just points are very popular.
06:59 And the point system is often a Fibonacci sequence, which, but it's not really, it's just kind of Fibonacci.
07:05 So I can't remember the numbers right off the top of my head.
07:07 I think they're like one, two, three.
07:10 We usually skip three.
07:11 So one, two, either four or five and like eight sometimes.
07:16 And then like 13 and 40.
07:18 So it isn't really quite fit normal Fibonacci, but I think that's where people took it from.
07:24 So we've been using them at work as well lately, but the numbers, it's kind of like t-shirt sizes, but I don't know.
07:32 None of these things really fit.
07:33 But the fruit salad estimation scale actually kind of fits.
07:39 So they've mapped one, two, three, five, and eight to grape, apple, cherry, pineapple, and watermelon.
07:47 And I like these ideas because they're kind of like how easy they are to cut up something and how easy they are to eat them.
07:55 So like a grape is trivial.
07:56 You know, you just pop it in your mouth.
07:58 It's no big deal.
07:59 You don't even have to cut it up for a fruit salad.
08:01 Although I usually do.
08:02 An apple.
08:03 Everybody knows how to cut up an apple, but it's a little more food.
08:07 So it takes a little bit more and it might take some more time.
08:10 A cherry.
08:11 It's also easy, but there's some unknowns in it because of the pit.
08:15 And a pineapple.
08:17 Yeah, you can't just eat that.
08:19 You've got to actually put some work into it.
08:21 Some people don't know how to cut it up and it's a little messy.
08:26 You're going to have to get your hands dirty for that one.
08:29 And a watermelon.
08:30 All bets are off.
08:31 Nobody knows.
08:32 You don't know what you're getting into until you cut open the watermelon.
08:35 So I like that as the large size.
08:38 There's more description on this article.
08:40 And then they throw in some nice ones.
08:42 Tomato and avocado.
08:43 Tomato and avocado do not map to points.
08:46 But tomato is unknown.
08:49 I mean, are you a fruit or are you not?
08:52 And you need more information before you can estimate it.
08:55 And it really doesn't belong in the fruit salad until you change it into something else.
08:58 And then one of my favorites is avocado.
09:02 That's something that you just get.
09:03 You can't really scope it very well.
09:05 And it's probably urgent because it'll go bad quickly.
09:08 These are great.
09:09 I like this concept of thinking about them here.
09:12 Yeah.
09:12 So I think that somebody needs to put these fruits in an official product.
09:17 That would be cool.
09:18 That would be cool.
09:19 You know, another one that comes to mind here is a mango.
09:21 Yeah.
09:22 Yeah.
09:22 You know, those are tricky because I like to cut them like in the orientation of the husk
09:27 or whatever the thing in the middle is, the giant seed.
09:29 But you got to hack into it a little bit before you can even figure out what that is.
09:33 So you kind of start out unknown and it's slippery.
09:35 You may hurt yourself on it.
09:36 But it's really, I don't know, it's a high value once you get it out of there.
09:41 I don't know.
09:41 Mango.
09:42 And sometimes you can't tell until you get into the mango if it's even good or not.
09:46 Exactly.
09:47 Yeah.
09:48 Yeah.
09:48 I think mango is in this category somewhere.
09:50 But this is a really cool idea of thinking about it because it's super hard to be very
09:54 accurate when you're estimating stuff.
09:56 And what I like about this is it just brings that together in a pretty clear way, right?
10:01 They're not like, well, how many hours is it going to take?
10:03 It's going to take three or four hours.
10:04 Like, no, no, no.
10:05 We're not talking.
10:06 Like, I can't possibly give you that answer.
10:08 It's like, all right, fine.
10:10 It's four hours plus or minus 16 hours.
10:13 Yeah.
10:13 And then that kind of stuff.
10:14 If you do points, people always have like some conversion to hours anyway, and it's annoying.
10:19 I think it'd be cool to if somebody said, you know, I got a manager or somebody saying, hey,
10:24 hey, how many, how much time we have left?
10:27 And be like, well, we have three grapes and a cherry left to do.
10:30 Yeah.
10:32 Just don't talk about it by lunchtime.
10:34 Anyway, I am hungry now.
10:37 So, instead of doing another topic, we should just talk about how awesome we are.
10:42 How awesome your training courses are.
10:43 Thanks.
10:44 Well, so this episode is brought to you by us, and we both are doing stuff we would love for
10:49 you to check out.
10:49 So, over at Talk By The Line Training, we have a bunch of courses.
10:51 I think we're up, probably by the time that this goes out, we're up to almost 200 hours
10:56 of courses and a couple hundred hours of exercises.
10:59 So, lots of stuff to be learned over there.
11:01 But I want to call out, if you have a company and your company has a training budget or a
11:07 training plan, you know, reach out to us.
11:09 We have special deals and offers and pilot programs to help get our courses started at
11:15 your company.
11:15 So, shoot me a message over at Michael at talkpython.fm, or just check us out over
11:20 there.
11:21 And if they're writing code, they should test it, right?
11:24 Definitely should test it.
11:25 And tell everybody, the Python testing with pytest is the best way to get started with testing
11:31 with Python.
11:32 And even though it's like 180 pages, the first two or three chapters will get you up
11:37 and running like in a day, less than a day.
11:39 So, you can get started right away and then you just get faster and more awesome as you
11:44 go along.
11:45 Indeed.
11:45 I take advantage of all those features and pytests that people might not know about.
11:49 Yep.
11:49 So, you know, one thing I think people come into programming often feel like if they're
11:54 going to be programmers, they have to be good at math.
11:56 Like, oh, I was really good at calculus, so I'd be a good programmer.
11:59 Or I never actually got algebra very well, so I'd probably be able to be a good programmer.
12:02 And I think that connection is often very much not true.
12:07 Like, I don't do math other than like basic arithmetic in my programming these days.
12:11 But some people do, right?
12:14 Some people come as engineers or they come as scientists and they actually do math frequently
12:20 and they want to do it with Python.
12:22 So, Vernon Thamaret sent over this cool project called Math to Code.
12:31 Have you seen this?
12:31 Yeah.
12:32 Yeah.
12:32 I was checking this out the other day.
12:33 It's pretty fun.
12:34 Yeah.
12:35 So, imagine you wanted to learn something by doing flashcards.
12:39 Right?
12:40 I'm going to show myself.
12:41 I'm going to flip through them and like see like a simple thing and then what the answer
12:45 to that is.
12:46 And this is kind of like that.
12:47 Like it starts out and says, what I want you to do is take the square root of something
12:51 using NumPy.
12:52 And it's all based on NumPy or just pure Python.
12:55 Like raise something to the power.
12:57 It's just X star star Y, for example.
12:59 But it just really quickly and simply takes you through that.
13:02 So, you type out the answer, hit enter.
13:04 It's all hotkey driven, which is great for a web app.
13:06 And it just kind of guides you through like practice experience of here's a math problem.
13:13 Solve it.
13:14 NumPy.
13:14 Yeah.
13:15 And it's so beautiful.
13:17 It is pretty, right?
13:17 Yeah.
13:18 Cool.
13:18 Yeah.
13:18 I honestly haven't made it to the end.
13:20 So, I don't know how many answers or questions or whatever there are or flashcards as I'm calling
13:26 them.
13:26 But it is open source on GitHub, which is pretty cool.
13:30 So, you can go in there and, you know, check out the source code and play with it.
13:35 And yeah, it looks like 13 questions, but it's on GitHub and the questions are just marked
13:42 down.
13:42 So, you could go add as many as you would like.
13:45 Actually, that's pretty cool.
13:46 Yeah.
13:46 But what also is interesting, just at a more higher metal level, maybe you don't care about
13:51 finding, you know, the square root of something in Python, is the building blocks.
13:57 So, if you look at how this thing is built, and like I said, open source on GitHub, you
14:01 can check it out.
14:01 It's built running Python on the client side.
14:05 What?
14:05 Really?
14:06 Yeah.
14:06 So, it's built using Sculpt, which is a JavaScript implementation of Python.
14:11 And then it has Sculpt NumPy for the subset of NumPy running on a client side that it wants
14:18 you to experiment with, right?
14:20 Like NumPy.square root, for example, or MPs.square root.
14:24 It has KTX for rendering LaTeX on the browser side.
14:29 It has Next.js for front-end, Tailwind CSS, which my friend Mark just told me about, which
14:34 is a really interesting alternative way to like CSS front-end frameworks.
14:38 I like Bootstrap, but different Remark from Markdown on the client side, Gray Matter, all
14:44 sorts of stuff.
14:44 So, there's a lot of cool building blocks here, regardless of whether or not you're actually
14:49 into the questions.
14:49 Yeah, this is awesome.
14:51 That might be more interesting, actually, than the thing, right?
14:55 Because I honestly don't care about learning the math features generally.
14:58 It's nice, but it's just not as it might do.
15:00 Yeah, but this sort of model of like have a, I mean, if you look at it, I don't know if
15:04 you already said this, but if you look at it, you've got like some explanation and a question
15:08 on the left, a place to type in and submit your answer on the right, and then there's even
15:13 a place where you can like set up a hint and show the answer or a hint for somebody.
15:18 And having all this just, it looks very nice, and having like this as an example for somebody
15:26 else.
15:26 I could totally see like a teacher running with this to help their students learn really
15:31 pretty much anything.
15:32 Yeah, it doesn't have to be exactly Python, as long as you can verify it with Python.
15:36 Yeah, cool.
15:37 Yeah, yeah.
15:38 Tell us about the PEP.
15:38 There's always a PEP to be discussed.
15:40 I've learned about a couple of new PEPs in the 3.9 time frame.
15:43 Right, so this is the 3.10 time frame.
15:47 So, where everybody should be using 3.8 now, and you should be testing 3.9, especially if you
15:54 have a package that depends on, that people depend on, so that when 3.9 is then official,
16:00 it'll all work.
16:01 But people are already working on 3.10, of course, and one of the PEPs for 3.10 is PEP 6.22,
16:08 and it's not official yet.
16:11 It's in draft status, but there's some cool people working on it, including Guido, and I
16:18 think it's super cool.
16:19 Have you taken a look at this?
16:21 I have taken a look at it.
16:22 It starts out to me feeling like a switch statement.
16:25 Yeah.
16:26 But there's a lot more going on here.
16:28 It's called structural pattern matching.
16:30 And right off the bat, they note that there have been previous PEPs before that have tried
16:36 to put switch case statements in Python, and they've been rejected.
16:40 I don't know why they were rejected.
16:41 It's kind of something I didn't pay attention to.
16:43 But this, yes, instead of a switch case, it's a match case statement and a multiple statements.
16:51 But the neat thing is there's all these different...
16:54 So when we think of like a switch case statement in like from C, it matches by equality or value.
17:00 You switch on some variable name or some expression.
17:04 And if the answer matches one of the case statements, then you run that part of the code.
17:10 So that would be in the PEP 622 world, that sort of a use model would be like the literal pattern or the constant value pattern, basically with equality and stuff.
17:20 But it does more than that.
17:21 You've got name patterns so that if you just have a whatever, if these will always...
17:26 If nothing else succeeds prior to it, you can just have a variable name and it just assigns whatever you're passing in to that name and you can use it there.
17:36 My first thought was, what's the big deal?
17:38 You already have the variable name or the value.
17:41 But this new value in the name pattern is only available in that.
17:45 It isn't assigned otherwise if that didn't get hit.
17:48 So that's kind of some useful, neat things.
17:51 Constant pattern is kind of the same, but then it gets interesting.
17:54 So I think it'd be worth it just for that.
17:57 But you've got sequence patterns where you can do...
18:01 It works like unpacking assignment stuff.
18:03 You've got mapping patterns that are like similar to sequences, but for like dictionaries.
18:10 And class patterns where you can have like a custom class or a class that it might be and you have a match object.
18:18 It's similar to equality, but you could have...
18:22 It could be different than equality.
18:23 And then you can combine them with ores so you can match cases if multiple things are true, like a boolean expression in there.
18:31 I don't think it's a full boolean expression, but at least ores work for pipes.
18:37 Guards.
18:38 So you can say if this pattern matches and then have an extra if expression so you can clarify it even more.
18:45 And then even sub patterns.
18:47 And at that point, I kind of got lost.
18:49 So just there's a lot here.
18:51 I don't think it's going to clutter Python up.
18:54 Actually, I've seen some examples of how this would dramatically simplify some Python.
18:59 Yeah, it's interesting.
19:00 What's surprising to me is how many types of things it's trying to do at once, right?
19:05 Like it's not just like, oh, let's have a switch statement with like a slight variation.
19:08 Like it's...
19:09 There's a ton of stuff going on, including things like if you switch on an enumeration, you can just say dot attribute and it'll try to like pull that attribute out of that type and check it.
19:21 And yeah, it's pretty interesting.
19:23 One thing that's missing here that I would love to see is range matching.
19:29 Right.
19:29 So I could say it's in the range of zero to 10.
19:33 Match this case.
19:34 If it's a range of 11 to 100, do this other thing.
19:38 Actually, so I have my package, the switch link package, which adds switch to Python and it has those types of things.
19:45 So I actually sent that over to one of the people working on this PEP and said, hey, this is really cool.
19:50 You know, check out some of the ideas from this one, like especially the range matching and see if it makes sense here.
19:56 Because it's so common that you would want to say like this range is this case, that range is that case and so on.
20:04 And we even talked about a package a while ago.
20:06 I can't remember exactly what it was called, which is unfortunate.
20:10 We've covered too many things.
20:12 But it was basically you could give a like a number or a value and then this range and you could ask, is this thing in that range in some real simple ways?
20:20 So it'd be cool if like that was all combined.
20:22 You might be able to do it with the if guard though.
20:24 So you could say like, you know, match X if X is within, you know, in this range.
20:30 Yep.
20:30 Yep.
20:31 It's true.
20:32 Yeah, we'll see.
20:33 I mean, at that point, like if you're writing a lot of complicated if statements, you might as well just write if statements.
20:38 Right.
20:40 Yeah.
20:40 Yeah.
20:41 Although, I mean, it's just always, I don't like it when I see like these, the if else ladders.
20:46 So I think that this is more than, of course, more than just replacing the if else ladders.
20:51 It's also doing things like unpacking and other sorts of cool stuff.
20:56 But you're right.
20:57 Yeah.
20:57 There's a lot going on here.
20:58 There is.
20:59 There is.
21:00 But it's cool to see innovation around this.
21:02 I do feel like that thing, that general idea is missing from Python.
21:06 I know people say you could just use a dictionary or stuff, but there's like a lot of cases where if else is buggy, hard to maintain, or like these other cases are very, you know, verbose and so on.
21:18 Anyway, I'm happy to see this, I think, depending on how it comes out.
21:21 It's very complicated, but the idea is good.
21:24 So one thing that we've talked about a lot, Brian, is how do you host your own private PyPI, right?
21:30 pip install a thing, but I want to be able to pip install and version, like say you work at a large company, you probably have libraries, packages that you've shared across projects.
21:40 How do you like have the pip style package management, but for you?
21:45 Well, we've got a custom PyPI at work.
21:47 That's right.
21:49 And that's fine.
21:49 That's fine.
21:50 The more global you are, the harder it is to maybe do that well without people getting a hold of it.
21:56 Like, obviously you want to protect that code because that's internal private code, but at the same time you want to share and version it.
22:01 So there's all sorts of options that you can set up and take care of that.
22:05 But there's this new thing, which Tormod McLeod has said over our way, called Code Artifact from AWS.
22:14 Neat.
22:15 Yeah.
22:15 So the idea is it is a general purpose, basically package management system for a variety of things.
22:23 So right now it works with Java, with Maven and Gradle.
22:27 For JavaScript, it has NPM and Yarn.
22:30 And for Python, it has pip and Twine.
22:32 And basically you can just set it up in AWS and tell it to go.
22:37 And it'll take care of all the storage and the security and all that kind of stuff.
22:41 And then you can just pip install all the things.
22:43 And it also is backed by the real PyPI or the real NPM.
22:48 And you can whitelist stuff.
22:50 You say, okay, if somebody pip installs requests, just get the real requests and stay in sync with that, but let them have it.
22:57 But if they pip install the misspelled request, I think you can say don't let them have the typo squatting hacker version.
23:05 Yeah.
23:05 So these sorts of solutions are pretty interesting to be able to have basically a cache of PyPI stuff and then also your own stuff.
23:14 So you push to it just like often you publish it.
23:18 I don't know about this one, but often some of these you use Twine or something to push just like you normally would.
23:24 But it doesn't go to PyPI.
23:26 It goes to your own thing.
23:27 Yeah, it's pretty neat.
23:28 It reminds me of Artifactory, which people might have heard of, which looks really cool.
23:34 However, if you look at the pricing, it starts at just $2,900 a year for the base version.
23:42 The pro version is $14,000 and it goes up from there.
23:45 So, you know, this looks like one of those cases where one of these cloud services from places like AWS and so on is coming along and going, you know what?
23:52 We got you.
23:54 And it's not $14,000 a year or whatever or a month.
23:57 I don't know.
23:57 Whatever the unit was I said there per year.
24:00 Yeah.
24:00 I think to some degree, I believe GitHub is working on something like this as well.
24:04 I can't remember what it's called over GitHub, but it doesn't have Python yet, which is why I haven't jumped up and down about it.
24:11 But I think it will.
24:12 I think they're working on it.
24:13 Well, supposedly like warehouse was something you could just use that is used for, well, I guess they don't call it warehouse anymore.
24:19 PyPI.org, the new PyPI.
24:22 Yeah.
24:23 So, I think that you can deploy that yourself, but there's not, I haven't seen very many people like, well, one, I'd like to see people write instructions on really how to get that up and running for yourself.
24:33 And I'd also like to see some like, you know, warehouse as a service sorts of things.
24:38 I mean, why not?
24:39 Some free money laying on the table there, people.
24:41 Yeah, that's a good point.
24:42 That's right.
24:43 All right.
24:44 What's this last one?
24:44 I wanted to bring up Invoke.
24:46 And it's at, what, pyinvoke.org is where you can see the documentation for this.
24:53 And to tell you the truth, we've had it on our list for a while and I've tried several times and couldn't get it to work, but I had some confusion.
25:01 So, then my confusion was the product, when you install it, you install it with pip install invoke, not with the py part.
25:09 But there is a pyinvoke on PyPI, but it does something different.
25:13 So, the invoke that I'm talking about is invoke without the py in front, but the website is pyinvoke.org.
25:22 Okay.
25:23 If you're confused, I'm confused, but we've got it in the show notes.
25:26 But why do we care about this?
25:27 We care about it because it does make me feel, I like make files.
25:31 I think make files are fine.
25:33 There's parts of them I don't like.
25:35 Like, I don't like that the tab, like, it's the only thing in my life that I have to use tabs for because I usually use spaces in Python.
25:43 Make files have tabs.
25:44 And often things like cleaning out your, building your documentation or kicking off your tests or deploying or a lot of those other book maintenance things for a project you put into a make file.
25:57 And some people use talks for that, and you can.
26:00 But invoke is intended to do that sort of thing, but with Python code.
26:05 So, with invoke, you just create a little task.py file with these little types.
26:11 You just have little functions that you decorate with the at task decorator.
26:16 If you have it installed, you can just say on the command line invoke and then the name of the function.
26:22 So, if you have a build function, you can say invoke build, and you can pass in command flags to it.
26:27 And it's just pretty easy to run something.
26:29 So, something like you would use make files for, you can have it without any make files.
26:34 Yeah, that's cool.
26:35 And you get to write Python for your scripting, right, basically?
26:38 Yeah.
26:39 The project looks like, I'm not quite sure if this is recent or old.
26:43 It says that it was intended for building documentation, but it does look like there's some examples on how to combine it.
26:49 I don't see why you couldn't use it to run your tests and run all sorts of other stuff, too.
26:54 Because it's just, it's got things like you can run Python code, but you can also run command line.
26:59 It can launch a command line tools and all sorts of stuff.
27:02 Yeah, if you can run stuff off the command line, then you could do get pre-commit hook type stuff or all kinds of automation.
27:11 Or even cycle the version, increment the version numbers and all kinds of stuff you want to put together.
27:16 Oh, yeah.
27:17 That would be a good thing to put in there, version incrementing.
27:19 And then also just like things like deploying, like check linting, that's a good thing.
27:24 And then you can, so one of the neat things about make is different make targets can depend on each other.
27:30 And this one has dependencies as well.
27:33 You can have, like, for instance, build can depend on clean and it can have to run off and do a different target.
27:41 And you can make a whole mess of stuff in there.
27:43 Or you could keep it clean.
27:44 But I like things like this to have, I mean, one of the reasons I'm not even, I don't mind make files.
27:50 But people that are not from a Unix or don't come from a Unix background have no idea what to do with a make file.
27:56 Yeah.
27:57 It's good for the team to make it easy for them.
27:59 Yeah.
27:59 Yep.
27:59 Indeed.
27:59 All right.
28:00 That's pretty cool.
28:00 I like to use this.
28:01 And I just got to think of a reason, a use case for it.
28:04 And I will.
28:05 It looks great, though.
28:05 Well, that's all of our six items.
28:08 Actually, I've been, like, totally swamped at work.
28:11 I don't have a lot of extra things to share with people.
28:13 Do you have anything extra for us?
28:14 I have a mystery that we can discuss.
28:17 You have a mystery?
28:18 Yeah, apparently.
28:19 You just talked about Python 3.9, and it's in beta, which means it's getting no new features.
28:25 It's just getting tested and ironed out.
28:27 And there was Python 3.9, beta 1.
28:30 And then there, Hito announced, oh, hey, everybody, here's Python 3.9, 0.
28:35 Beta 3 is out for immediate testing.
28:37 And somebody disappeared beta 2.
28:41 So the problem, apparently, with beta 2 was somehow the way that it looked up certificates was busted.
28:50 So if you, like, installed it from source and just ran it, it would be fine.
28:55 But if you installed it from the installer, all of a sudden, every web request that went to HTTPS or something along those lines would fail.
29:02 So that's not good to break the networking subsystem of Python because a lot of things depend on that.
29:09 And so they quickly ditched that one and fixed it and rolled out beta 3.
29:12 Okay.
29:13 And just about the time that this is released, so on June 29th, we'll have beta 4, which presumably will still make web requests successfully.
29:22 It won't have to be disappeared.
29:23 So anyway, just some Python 3.9 news.
29:26 Beta 3 is out.
29:27 Beta 4 will be out days after this comes out.
29:30 Or actually, maybe even before.
29:32 So there is no beta 2.
29:34 Before will be after or before will be before?
29:37 Before will be before, I think.
29:40 But it might be after.
29:41 I'm not sure.
29:41 So I've got a joke for you I grabbed here off of Geek and Poke, which is like a cartoon strip.
29:51 Okay.
29:52 All right.
29:52 So it's a mom and a son.
29:54 And you have kids.
29:57 I'm sure you know how this goes.
29:58 How was your day?
29:59 Eh.
30:00 Good day?
30:01 Yeah.
30:02 What did you learn at school?
30:03 Not much.
30:04 You were there for eight hours, continuously getting instructed like you didn't learn more
30:10 than like half a cent.
30:11 Like, eh.
30:12 Yeah.
30:12 Right.
30:13 So, but if this child happens to be a geek, there's another ploy in which you can employ,
30:18 another technique you can employ to get them to tell you more about their day.
30:23 So it goes like this.
30:24 It says, hi, Darlene.
30:25 How was your school day?
30:26 And like sort of a blank stare.
30:28 Hi, Darlene.
30:29 How was your school day?
30:30 Dash, dash verbose.
30:31 Yeah.
30:33 I totally wish I had verbose flags on my kids sometimes.
30:36 Yeah.
30:37 Also, sometimes a dash Q, like a quiet one would be good sometimes too.
30:42 Yeah, exactly.
30:42 The dash, dash quiet.
30:44 If I got to pick one or the other, I'm going to go for the dash, dash quiet as an option.
30:50 Yeah.
30:51 Especially for young kids.
30:53 Yeah.
30:53 Exactly.
30:54 Exactly.
30:55 Daddy needs a little piece, dash, dash, quiet.
30:59 Yeah, definitely.
31:00 All right.
31:00 Well, that's it for the episode, I guess.
31:02 Yeah.
31:03 Thanks a lot again.
31:04 You bet.
31:04 See you later.
31:05 Bye.
31:05 Thank you for listening to Python Bytes.
31:07 Follow the show on Twitter at Python Bytes.
31:09 That's Python Bytes as in B-Y-T-E-S.
31:12 And get the full show notes at pythonbytes.fm.
31:15 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.
31:20 We're always on the lookout for sharing something cool.
31:22 This is Brian Okken.
31:24 And on behalf of myself and Michael Kennedy, thank you for listening and sharing this podcast with your
31:28 friends and colleagues.