Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #329: Creating very old Python code

Return to episode page view on github
Recorded on Thursday, Mar 30, 2023.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:06 This is episode 329, recorded March 30th, 2023.

00:11 And I'm Brian Okken.

00:13 I'm Michael Kennedy.

00:14 And before we get started, I want to do a couple things.

00:18 I want to thank Microsoft First Startup Founders Hub for sponsoring this episode.

00:21 Please listen to their spot.

00:23 We've got a very special random guest appearance or voice for that ad read.

00:29 So that'll be fun.

00:30 I also, if you're listening to this, I'd like to encourage you to, and you've never watched the live show,

00:37 I'd like to encourage you to watch our live show on YouTube or streaming.

00:41 Today is Thursday, but we usually record Tuesday at noon or 11.

00:47 No, Tuesday at 11.

00:47 Yeah, I should have practiced this.

00:49 Anyway, but welcome.

00:51 And the people that are here today are watching on YouTube.

00:55 Thanks for watching.

00:56 And why don't you kick us off, Michael?

00:59 I got something.

01:00 I think it'll resonate with you folks.

01:02 Maybe you already are aware of this.

01:04 This is news to me.

01:05 Comes to us from Brandon Hannigan.

01:08 So thanks for sending that in.

01:10 And it's an environment variable.

01:12 And in and of itself, it's interesting.

01:14 That it leads to many more environment variables you can play with is also pretty awesome.

01:19 So this one is about the Dunder PyCache folder.

01:23 So I don't know how you feel about these, Brian.

01:26 I'm glad they exist.

01:28 I'm not necessarily super glad that they're spread out a bunch of random folders.

01:34 So like a lot of my projects have many different modules and different folders, you know, submodule type setup.

01:39 And when I run them, they all get filled up with Dunder PyCache folders with startup PYC, you know, compiled Python.

01:47 Like people might think, I think Python is compiled, but yes, Python is compiled.

01:51 It's just then interpreted, not, you know, all the way to machine instructions, right?

01:55 So those files end up in the Dunder PyCache, which spread throughout your project structure.

02:00 Sometimes I want to make a copy of that.

02:02 I want to move that around.

02:02 I want to zip it up and share it.

02:04 And I don't want those things in there.

02:05 And so I'll have to go in and search for all those and remove them, you know, recursively, which is not at the end of the world.

02:10 But I'd rather they are not there.

02:12 Or if they were there, could they just go in a top level thing?

02:15 You know what I mean?

02:16 Like, could they just go into a single Dunder PyCache that understands the whole structure, not, you know, every file being treated as if it's unrelated?

02:24 Yeah.

02:25 I mean, it's better than it used to be of having the PYCs right next to the Python files.

02:29 Yes.

02:29 It is an improvement.

02:31 Yeah.

02:32 But this thing that Brendan said in, you can set the Python PyCache prefix, which is a path.

02:39 Maybe it should be called Python Cache folder.

02:42 I don't know.

02:42 Anyway, what you do is you set this in your environment variable, maybe a new user account, maybe in the activation of a virtual environment.

02:51 If you want it to be a one-off type thing.

02:53 I don't know.

02:54 Then when Python goes to create these, it goes, oh, they don't want the Dunder PyCache.

02:59 They want it over in this directory over there.

03:02 And so it'll make, you can isolate all of your Dunder PyCache stuff into a separate location on your user profile.

03:09 You can go and just blast that away whenever you feel like.

03:11 But most importantly, it's not within your source code.

03:14 If you like zip it up and hand it out or things like that.

03:17 Oh, wow.

03:18 Okay.

03:18 Yeah.

03:18 That's great.

03:19 Yeah.

03:19 It says, if this is set, Python will write star.pyc files in a mirror directory tree at this path instead of in Dunder PyCache directories within the source tree.

03:30 This is equivalent to specifying the dash x PyCache prefix equals path option.

03:34 So pretty cool, right?

03:36 Yeah.

03:36 I also didn't know about the dash x though either.

03:38 So that's pretty cool.

03:39 Yeah.

03:40 This page that I'm linking to is at the top.

03:42 It has all the command line options.

03:43 And then almost all the command line options have an environment variable thing if you want it to just be the default all the time and you don't have to set it.

03:51 So there's a bunch you can come through here.

03:54 So Python path you can set.

03:56 Python startup.

03:57 So these are the Python commands that I'll execute whenever you start Python, which is kind of interesting.

04:03 Optimize.

04:04 Breakpoint.

04:06 Debug.

04:07 The one we talked about.

04:08 You can set up a hash seed so you can get repeatable deterministic hashing.

04:13 A bunch of stuff is here.

04:15 People can check out how you look at warnings, how much warnings you want to see, whether or not there's buffering.

04:20 So, you know, you'll see sometimes things like the standard out will come after the standard error, but the standard error in time actually came after the out, right?

04:32 Because the buffering got out of, you know, they hit the buffer at different periods.

04:36 So you're going to do things like turn that off, turn on malloc stats if you want to track that.

04:40 So there's like a bunch of things you can come in here and play with.

04:44 But I think the PYC one's an interesting one, especially for people who hand out code.

04:47 You know, like if you're doing like a training or a tutorial and you're like, here, I want to give everybody this.

04:52 You got the PYC.

04:53 I was just looking through there because I'm surprised that you can't specify which XKCD comic to link to.

05:00 I know.

05:01 When I import anti-gravity, which one?

05:03 Don't worry, we'll get there.

05:05 Cool.

05:07 All right.

05:07 Well, that's what I got for this one.

05:08 The Python PYCache prefix.

05:11 Check it out.

05:12 Nice.

05:12 Yeah.

05:13 I wanted to talk about GUIs.

05:14 We haven't talked about GUIs for a while.

05:16 Actually, we haven't.

05:18 We were on such a kick.

05:19 We were on such a kick.

05:20 Yeah.

05:21 But several people have mentioned this to us, so we thought we'd cover it.

05:26 It's a package called NiceGUI.

05:28 And normally, actually, when I think about GUI, I think about like actual, not web stuff, but user interface stuff that's on the desktop.

05:35 But this is a browser-based thing.

05:38 So this is a package that says it's easy-to-use Python-based UI framework, which shows up in your web browser.

05:45 Buttons, dialogues, markdown, 3D plots, and more.

05:48 What's cool is you can play with it all before you even try it.

05:52 So the documentation is really great.

05:56 And even just here, I thought this was just like a screenshot or something.

06:00 No, you can just like, this is part of it.

06:02 You can move it and interact with it right here in the first page.

06:06 It's pretty cool.

06:06 The full documentation is really pretty great, too.

06:11 I actually want to try to play with this because the code really looks pretty easy to write.

06:15 So for some quick, maybe dashboards or some quick control stuff that you're okay with doing through a web browser, why not try it out?

06:23 And some of these are pretty cool.

06:26 I was playing with text input.

06:27 So it's talking about validation and stuff.

06:31 So you can have some text and you can just start typing.

06:33 And it's saying, oh, that's too long.

06:36 So you can, I mean, this validation is pretty simple of just checking length.

06:40 But you can do all sorts of stuff like email validation or whatever you want it to do.

06:43 Because it's just like a function that's calling.

06:45 So kind of neat.

06:46 You got a validation there.

06:48 Knobs.

06:49 Knobs are fun.

06:49 I was playing with the knobs.

06:51 So just drag knob and turning.

06:54 Anyway.

06:55 I use a context manager to put it into the page with knob.

07:00 What?

07:00 With knob?

07:02 Interesting.

07:04 I wonder why.

07:05 I don't know.

07:06 Oh, to put the icon inside it.

07:08 So you basically, it looks like you're focusing the subsequent commands to be within the container of the knob.

07:14 Because the knob is like a circular progress bar type thing.

07:18 And you can put a volume up icon inside it.

07:21 Okay.

07:22 Anyway.

07:23 Just all sorts of cool stuff.

07:25 Joystick.

07:26 That's really.

07:27 I don't have a joystick to play with this out.

07:29 But some interesting naming there with the joystick.

07:33 But anyway.

07:36 So moving on.

07:38 Date pickers and all sorts of things.

07:40 Ooh.

07:40 That's nice.

07:41 Cool.

07:42 But UI elements.

07:43 If you're okay with trying something new.

07:46 A nice GUI might be right for you.

07:49 So that's it.

07:50 Interesting, isn't it?

07:50 You know, when I look at these types of frameworks that a lot of times I feel like what they say is,

07:56 HTML is terrible.

07:58 The DOM is terrible.

07:59 CSS is terrible.

08:00 Let's create a parallel Python or name your language equivalent where we put elements in the web page.

08:07 I'm like, hmm.

08:08 They may have their drawbacks.

08:10 But at least you have a ton of tools and stuff that apply to HTML and CSS and all those things, right?

08:14 Yeah.

08:15 But with this one, I think there's a lot of cool widgets and stuff that are here.

08:18 And it looks more like it's not like we don't like HTML, so let's make a Python DOM that you create the HTML with.

08:26 But rather, like, how do we make a cool interactive page based on these additional things like knobs and joysticks and sliders and stuff that's not easily part of HTML?

08:37 Yeah.

08:38 And the places where I would really use something like this are, I mean, this is some short code.

08:44 So especially internal tools or even just stuff for myself.

08:49 If I want to explore some data control like a database or got a bunch of controlling some system or something,

08:56 and I want to quickly throw something together, something like this would be great for just doing a one-pager or something to try it out.

09:05 I also think these types of frameworks would be pretty cool to bring into some kind of electron JS type thing where you're like,

09:14 and here's how you make it an app that doesn't actually look like a web page and give it to someone.

09:19 Yeah, so one of the things they bring up is like great for micro web apps, dashboards, robotics projects, like school robotics, stuff like that, smart home solutions.

09:29 Probably that joystick thing, right?

09:30 Yeah.

09:30 How do you drive your little ribbon around?

09:32 And then one of the nice things that I noticed about the documentation is they've got a bunch of demos.

09:39 Oh, these are the actual demos.

09:42 But there's examples.

09:43 Where did I find those?

09:45 Is it maybe under examples?

09:47 Well, anyway, there's a whole bunch of like actual code.

09:49 So there's repos around that you can try it out with different repositories.

09:55 Maybe it's just on the front page.

09:57 Anyway, I was impressed.

09:59 Oh, yeah, here we go.

10:00 Down at the bottom of the front page, there's like slideshows.

10:02 And even if you want to, will this work with FastAPI?

10:05 Apparently, there's a FastAPI example for just some quick repositories so you can try it out yourself.

10:13 Oh, maybe like an admin page type of dashboard.

10:16 Dashboard thing that you can play with.

10:18 Yeah, there's some OpenCV webcam.

10:21 Infinite scroll for galleries.

10:23 And the amount of like demos of components right there, but then actually specific examples where you can, you know, with the code, with repos that you can just copy and get started with.

10:36 That's pretty impressive that they put all that together right off the bat.

10:40 Yeah.

10:40 So, yeah, it looks like it's definitely worth checking out.

10:42 Do you know what else is worth checking out?

10:45 Our sponsor.

10:47 Yes.

10:47 Yes.

10:47 Microsoft for Startups, Founders Hub.

10:50 Thank you for sponsoring this episode.

10:52 And what was the key that you, how did you generate this code, the text?

10:58 Well, remember, I don't recall who suggested it because I had the American football coach motivational speech version variant last time.

11:06 And somebody said, well, what if it was like Ted Lasso?

11:08 So I said, hey, OpenAI thing.

11:11 Here's the Microsoft ad.

11:14 Could you rewrite it this time in the style of Ted Lasso?

11:17 Yeah.

11:19 So it's an odd episode.

11:21 So I get the honor of trying to be Ted Lasso, which I'm not going to get the voice.

11:25 So apologies.

11:26 And I did not grow up in the Midwest.

11:28 So anyway, let's just get started.

11:30 Hey there, team.

11:31 Gather around because I've got something real special to share with y'all.

11:34 Now, you know how much I believe in the power of teamwork and positivity, right?

11:39 Well, this opportunity I'm telling you about to tell you is just like the perfect assist to your startup goal.

11:46 I'm talking about the Microsoft for startups founders hub, folks.

11:50 Now, imagine, if you will, a locker room full of support for your startup, especially if you're keen on that, their artificial intelligence stuff.

11:58 We're talking over six figures of benefits that will change the game for your team.

12:03 They're offering you 150K in Azure credits.

12:07 And that, my friends, is like having the best player on the field on your side.

12:10 And what's more, the founders hub has given y'all a unique chance to access open AIs, APIs, and the new Azure open API, the Azure open AI service.

12:22 It's like having your own generative AI coach to help you come up with game winning strategies for your applications.

12:29 Now, I know how important it is to have the right support.

12:33 And that's why the folks at Microsoft are also offering one-on-one technical advice, helping you with your game plan, scalability, and security.

12:42 Plus, you'll be part of a network of mentors who know the startup world like the back of their hand.

12:49 I can't emphasize enough how amazing this opportunity is, friends.

12:53 And guess what?

12:54 It's open to everyone, no matter what stage your startup's at.

12:57 And no funding requirements.

12:58 Just take five minutes to apply, and you'll be on your way to reaping some massive benefits.

13:04 So come on, team.

13:05 Let's harness the power of AI for your startup and join Microsoft for Startup Founders Hub today.

13:10 Head on over to pythonbytes.fm/foundershub 2022 and sign up.

13:15 This is your chance to score big.

13:17 So don't let it slip through your fingers.

13:19 And just so you know, the ad you just heard was written by the same AI you'll get access to.

13:26 Ain't that something?

13:27 So don't wait any longer and sign up at pythonbytes.fm/foundershub 2022.

13:33 A big thank you to Microsoft for supporting this show.

13:37 That open AI, that sure is something.

13:39 All right.

13:40 Speaking of something, let's talk about Ngrok.

13:44 Let's talk about Flask.

13:45 I can't decide.

13:46 Let's talk about both.

13:46 So this one I want to cover is an interesting one.

13:50 So I've talked about Ngrok before.

13:53 For those of you who don't know, like, unfortunately, their website, I don't know what's gone on,

13:56 but they redesigned it in a way they can't really tell what it does.

13:59 But it's just, anyway.

14:00 Ngrok, what it does is it lets you run a command locally and then share your web app,

14:09 whether that be for an API, someone needs to talk to the API, or just the web app itself.

14:15 So for example, Brian, imagine you had created a cool demo of that nice GUI thing.

14:21 And you wanted to let some people, you're in a meeting with your team, like, hey, you guys, y'all should check this out.

14:26 This is really, really cool.

14:28 And what you might do normally would say, well, let's just fire up a screen sharing and I'll drive it around.

14:34 But the interaction part of those widgets is really cool.

14:37 So it'd be better if you could just say and interact with this, right?

14:39 So if you fire up Ngrok, you just give them a URL that reverse SSH tunnels into your machine,

14:47 and then they can access it on the internet with their browser and everyone can play with it live, right?

14:51 Okay.

14:51 So that's really cool.

14:53 I recently used that for, I'm just about to release a course called Python Web Apps that fly with CDNs.

15:01 Like basically, how do you do really awesome stuff with CDNs plus Python and Flask and all those things to make your app way, way faster?

15:08 Well, in order to put that together and test it, you've got to let a public CDN get access to your dev machine, which like, how does that happen?

15:16 Ngrok is how that happens.

15:17 Same thing with our mobile apps, like, you can see, like, right here.

15:20 We had this problem where some of the data wasn't being passed through as headers correctly to the server.

15:27 And we're like, we cannot figure out why this is not working.

15:29 It's clearly in the headers collection.

15:31 Why is Python not seeing those?

15:33 And it turns out there was like a weird case sensitivity issue or whatever.

15:37 But I just fired up Ngrok, pressed debug on PyCharm and said, all right, try it again.

15:41 And then boom, I'm like stepping through, like on a mobile device, I'm stepping through its interaction with the APIs.

15:47 I'm like, oh, I see.

15:48 Here's what's happening.

15:49 And then we fixed it.

15:49 Super easy.

15:50 All of that is to set up Flask-Ngrok.

15:53 So all of those benefits are awesome.

15:56 But like what I got to do is I have to go fire up Ngrok, go overdo the thing and then come back.

16:01 Right.

16:01 So it'd be cool maybe if I could just press go, either Flask run or just go in PyCharm or VS Code.

16:09 And it would just, in addition to starting up Flask, it would also start up Ngrok, pointing back at whatever the right port is.

16:15 Right.

16:16 So basically that's what this is.

16:17 You just wrap the app in run with Ngrok.

16:21 So you get a run with Ngrok app.

16:23 And then when you say Flask run, it fires up the local version, but it also fires up an Ngrok URL that you can share with people.

16:31 Oh, cool.

16:32 Yeah.

16:32 So not a huge, huge feature because sure, you can run Ngrok on your own, but I think it's kind of cool.

16:38 Basically, that means whenever you run your Flask code, your Flask app for debugging or for dev or whatever, there's always a publicly accessible address that you can share with other people or you can type into some other tool.

16:52 I want to validate an RSS feed.

16:54 I want to have my API, some API client that is not on my machine like a mobile app or some other, you know, think if this, then that, or one of those types of things.

17:06 All those can just come back right in because you always have this public address available, which I think is pretty cool.

17:11 That's pretty cool.

17:12 Yeah.

17:12 So if that sounds useful, people can check it out.

17:15 Oh, man.

17:15 Okay.

17:16 So I was just thinking, I wonder if random address, because like I need another URL that I'm not doing anything with.

17:21 But I was wondering if random address was taken and random address is taken.

17:26 Is it random addresses?

17:27 No, we have enough.

17:31 I've got several that I'm not using.

17:34 Yeah, that's awesome.

17:36 All right, cool.

17:36 Anyway, people can check this out if they are doing a lot with Ngrok.

17:40 So by the way, one thing that I think would be interesting, I didn't see in the docs whether or not this is easy, possible, impossible, whatever.

17:48 One of the things you can do is you can set it up so that this random address is repeatable.

17:53 Otherwise, if you just rerun it, you'll get a new random address, which you got to keep typing in by doing like subdomain type things and stuff.

18:00 You've got a paid account.

18:01 I don't know if it's possible to have it do that or not, but it would be cool if you could make it random, but not completely random.

18:07 Not completely.

18:09 Just random once.

18:10 Yeah, random once, and let's stick with that for a while.

18:12 All right.

18:13 What do you got for our last one?

18:14 I want to talk about async.

18:17 So Will McCoogan wrote an article called No Async with Python.

18:23 No async, async.

18:24 And that confused me.

18:27 But it's a really well-written article.

18:29 There's times where if you want to take advantage of async, you kind of have to have async all the way up and down the call stack, right?

18:39 Or maybe.

18:40 That's what it seems like, at least, to make sure this all works.

18:44 And so that's actually what I guess Textual did at one point is asynced all the things.

18:50 But Textual now is async optional.

18:54 And so this article discusses how they do that.

18:57 And the first part is if you're passing in a callback to, if you're providing a mechanism for somebody to pass a callback in,

19:05 and that callback can, you want it to be either just a normal function or an async function.

19:10 He's utilizing the await me maybe pattern that he borrowed from Simon Willison.

19:17 So Simon Willison wrote about this a couple years ago.

19:20 And he shows, he scrolled almost to the bottom.

19:23 There's this, basically, there's a way to, you have an async function, and it calls.

19:29 So the caller is async, and you're calling something that could be either async or not.

19:34 And you just call something and check to see if it's a coroutine and then await it or don't await it.

19:39 And that's pretty much what Will is showing is, you know, inspect the callback, inspect the result to see if it's awaitable or not.

19:48 Doing it a little bit different method, but similar sort of effect.

19:52 So that's neat.

19:53 So you can provide a mechanism to add a callback that could be async or not optional.

19:59 But the other part around is, is if you're, if you're providing an async service that could be called in either an async or non-async, you want it to be called by anybody.

20:10 Because sometimes, like, he gives an example of mounting a new widget into Textual.

20:17 The caller might want to care, might care about when that's actually done.

20:22 So they might want to wait for that.

20:23 But they might not.

20:24 They might just, like, keep going because apparently Textual handles it all correctly anyway.

20:28 They won't let something happen.

20:31 But the caller might not care about when it's done.

20:33 So to be able to allow both async and non-async callers to call an async method, that's a little bit yuckier code.

20:42 But he provides it.

20:43 So there's this class, this await mount option.

20:48 So there's, I'm not going to walk through all this code.

20:51 But basically, there's a way to do it.

20:53 And Will has it, has the method to allow you to have.

20:56 And I think that's kind of neat to be able to provide services and APIs that can be called both in async and non-async ways.

21:05 Now, hopefully, this still is kind of ugly.

21:07 So hopefully, as a community, we can come up with a little bit cleaner solution.

21:11 But at least there's a solution.

21:13 So it's kind of nice.

21:14 Yeah, Will did a nice job of this.

21:16 And I think it's really a huge benefit that Textual has the ability to be async, but doesn't force you to be async.

21:23 Because if you're already writing async code, you would like it to be because it's a benefit.

21:27 You can do more in parallel, be more responsive.

21:30 But if it means I have to take my non-async code and now convert the whole thing to know about some parts of it being async, well, that's a hassle.

21:38 And I think one of the things that drives me nuts about Python's async, there's a few little things that just make me crazy about it.

21:45 It's like, well, it's so close to awesome, right?

21:49 And much of it is awesome.

21:50 But for example, if I'm in a function and I want to say, here's some async code.

21:56 I want to just run it here.

21:57 So for example, async.io, get event loop, loop.run sort of thing, or just async.io.run to complete.

22:04 If it's already being called within an async function with some other event loop and you don't know about it, under certain times it'll crash and say there's already an event loop or there is no event loop.

22:14 You're like, well, give me just if I don't have one, give me one.

22:19 If there is one, just give me that.

22:20 I don't care.

22:21 I just need to run something async.

22:22 And there's always this weird, I'm not really sure what state I am.

22:25 And if I get it wrong, then it gives me a, it crashes.

22:28 And I was just like, ah.

22:30 So I think that makes it challenging to kind of go, this part we're just going to isolate off the async, which it sounds like Will did here, which is cool.

22:39 So that's really excellent.

22:41 Yeah.

22:41 Really quickly here, too, I've had a couple of shots at this myself as well.

22:47 Nothing like published really very much in terms of what Will's doing or what Simon talked about.

22:52 Like, for example, on FastAPI chameleon and the Jinja equivalent, like let's just put a decorator on top of a FastAPI function and then it returns the HTML view of that and stuff.

23:05 But those FastAPI functions, they can be synchronous or they can be asynchronous.

23:10 And so what it has to do is it has to say, is this, is this function a co-routine?

23:15 Okay.

23:16 The decorator has to return also an async one.

23:18 Otherwise, when you say async and it becomes not async, that's wrong.

23:21 But if it's async one, you can't return the async, right?

23:23 Like, so you've got to juggle this a lot, which is kind of a pain.

23:26 And then the other one, I created this thing, which I put up just as a gist that like just lets you say this async function, we're going to run it in a way that won't have a conflicting event loop complaint by constantly managing the background thread and just pushing the work over there and pulling the results back.

23:41 So, yeah, it's interesting.

23:43 But, yeah, that's a cool article.

23:46 Yeah.

23:46 And do you remember the Call Me Maybe song?

23:50 Call Me Maybe.

23:51 Yeah, I do.

23:52 Yeah.

23:52 Await Me Maybe.

23:53 So Chris May added, hey, I just defined you and this may be async.

23:57 But here's my variable, Await Me Maybe.

24:00 Nice.

24:01 Oh, well done, Chris.

24:02 Well done.

24:04 I love it.

24:06 I love it.

24:06 Well, I don't have any extras, Brian.

24:08 You got any?

24:09 I do.

24:10 We'll try to make them quick, though.

24:12 So PyPI has a blog now.

24:13 Oh, let's pop over to here.

24:15 PyPI has a blog now.

24:17 So anyway, go check it out.

24:18 There's a welcome article.

24:20 So that's nice.

24:22 Neat.

24:23 And then, OK, so another extra.

24:26 Apparently, Docker.

24:27 No, they're laying off plans of charging people for the free team plan, which is kind of a bummer for people like me that paid for it anyway.

24:37 But, you know, anyway, so that's cool.

24:40 Maybe I won't have to pay next year.

24:42 I guess they're offering refunds or something, but I'll look into it.

24:46 I guess there must have been a big backlash.

24:47 I haven't been tracking this, but.

24:48 Oh, yeah.

24:49 I mean, like it's been a scramble all over the place of people because there's sometimes it's a very minimal interaction with it.

24:57 And then suddenly we have to pay for it and you got to figure out how many users and how many seats and all that sort of stuff.

25:03 And yeah.

25:04 Or if you want to use it without.

25:05 So if you want to use it without the user interface, you can use it for free.

25:09 But if you like people asking, are are you using it?

25:13 Yes, we are.

25:14 Because we debug with it.

25:15 So.

25:16 So I'm glad they're backing off.

25:18 I still want to.

25:19 I mean, of course, it's a great service.

25:21 They should be able to make money somehow.

25:23 But there should be it.

25:25 So it's good news.

25:26 I only the only thing left is I have is a joke.

25:31 Do you want to do mine first or yours?

25:33 Let's hear yours first.

25:35 Let's go.

25:35 It's just sort of.

25:37 I was looking up.

25:38 I was looking up some documentation for pytest Cove and noticed at the bottom.

25:44 So there's a there's mark.

25:45 There's it provides a no cover marker, which is nice.

25:49 So you can say don't cover this test.

25:50 And then there's a fixture.

25:53 You can also use that as a fixture.

25:55 But then there's also the no cover fixture.

25:57 But there's a Cove fixture, which why would you use that?

26:00 Well, it says for reasons that no one can remember, there is a Cove fixture that provides access to the underlying coverage in an instance.

26:08 Some say this is disguised as a foot gun and should be removed.

26:12 And some things some think mysteries make life more interesting and it should be left alone.

26:17 I love finding stuff like that in documentation.

26:20 Some think mysteries make life more interesting.

26:23 Indeed.

26:23 Indeed they do.

26:25 Okay.

26:26 Fantastic.

26:27 All right.

26:27 I got a quick one for you as well.

26:29 This one, you knew an XKCD was coming.

26:32 Good reference earlier.

26:33 So this has to do with like some deep thinking into how to make your code last so long that it becomes legacy code and people can use it for a long time and maybe even curse its name a little bit.

26:44 So there's two parallel universes here.

26:48 On one, this woman just wrote this code.

26:51 It took some extra work to build, but now we're able to use it for all of our future projects.

26:57 And the caption for that is, how to ensure your code is never used?

27:02 Yes.

27:02 And then the other alternate world is, let's not overthink it.

27:06 If this code is still in use that far in the future, it will have bigger problems.

27:10 How to ensure that your code lives forever?

27:12 Yeah.

27:13 And the hover is surely no one, everyone will recognize how flexible and useful this architecture is.

27:20 Spend a huge amount of effort painstakingly preserving and updating this garbage I wrote in 20 minutes.

27:24 Yeah.

27:26 Well, I mean, there's so many examples of that, isn't there?

27:30 I mean.

27:30 Oh, yeah.

27:30 Yeah.

27:31 I mean, internally, there's tons.

27:34 There's like, oh, just throw this thing together, build script or whatever.

27:38 And it's just, we'll rewrite it later.

27:40 10 years later, we haven't rewritten it.

27:42 Things like that.

27:44 I mean, Flask was like a really quick hack, wasn't it?

27:47 Like a joke at first or something?

27:49 I think it was an April Fool's thing.

27:51 Yeah.

27:51 I think so.

27:52 Anyway.

27:53 And the other side is the lesson that I think people should learn is planning on reuse is just a mistake.

28:02 And I've been in many, many design meetings where it's like, let's not plan six years out into the future on this.

28:12 That's ridiculous.

28:13 We don't even know.

28:13 Because I've also seen people plan for it.

28:16 And it is reused.

28:17 And it is maintained.

28:18 But the things that you thought you were going to need to be variable are not the things that really need to change in the future.

28:24 It's something else.

28:25 Yeah.

28:26 Somewhere in the middle there lives a, let's not overthink this, get it out there.

28:30 Oh, let's take a moment and refactor it.

28:32 So it's like more reasonable in the way we now know it needs to be.

28:35 Carry on.

28:36 So my advice, keep the interface simple.

28:39 Keep it minimal.

28:40 Document it and test it.

28:41 And then if it grows, great.

28:43 Yeah.

28:44 Excellent.

28:45 Thanks for that.

28:45 That's funny.

28:46 Yeah, for sure.

28:47 And thanks everybody for showing up.

28:49 And thanks Michael again for showing up.

Back to show page