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


Transcript #305: Decorators need love too

Return to episode page view on github
Recorded on Monday, Oct 10, 2022.

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

00:04 This is episode 305, recorded October 10, 2022.

00:09 And I am Brian Okken.

00:10 I'm Michael Kennedy.

00:11 We got a whole bunch of stuff that's great.

00:13 We also want to thank Microsoft for Startups, Founders Hub, for sponsoring this episode.

00:18 We'll hear more about them later.

00:19 But do you want to start us off with something exciting?

00:23 Let's kick it off.

00:24 I have a theme this week, Brian.

00:26 Okay.

00:26 Before we get to it, if my voice sounds a little bit scratchy, I just want to apologize.

00:31 It's not that I'm sick.

00:32 It's that I was rocking out to the Scorpions last night.

00:35 They were here in Portland.

00:36 And even if they're 70, they still rock.

00:38 It was amazing.

00:38 I don't know how old they are, but they probably are up there.

00:41 I don't know.

00:41 Maybe being sick may have been a better excuse.

00:44 Yeah, maybe.

00:45 All right.

00:47 I do have a theme, though, for the week.

00:49 And let's kick it off with that theme.

00:51 This first one, both of these are recommendations.

00:54 The first one came to us from Matt Kramer.

00:56 Thank you for that.

00:57 And Jeff Glass, remember last time I said they announced PyScript?

01:03 That is Python compiled to WebAssembly running on top of PyIodide and Wasm browser, which is amazing.

01:11 So many cool things and so much potential there.

01:14 I pointed out that that was released and there were some breaking changes.

01:16 And it was like last minute that I got that.

01:19 So I just threw it in as an extra.

01:21 But now I had a chance to look at it.

01:22 So there's a bunch of changes.

01:24 And I just want to highlight some of the things for people.

01:27 So they're using semantic versioning.

01:30 And I don't fully understand this.

01:33 I guess it's just like month based.

01:35 Right.

01:35 So it's 2022.09.1.

01:38 That doesn't mean September 1st, though.

01:40 It was released on September 30th.

01:41 So about 11 days ago, 10 days ago.

01:45 And they just reiterate this project is undergoing lots of changes.

01:50 It's in its super early stages.

01:51 The calendar versioning doesn't really indicate that it's like 0.1 or whatever type of level.

01:57 But there's a lot of breaking changes.

01:59 So if you've worked with it before, just you want to read through this and figure out where things are going.

02:05 It doesn't look like anything's majorly broken and like you've got to rewrite a ton of stuff.

02:10 But it also, there are parts that will stop working, but they seem pretty easy to fix.

02:14 So first of all, like many Python programs, you need to express your dependencies.

02:20 You would do that through a pyproject.toml or requirements.txt.

02:24 Unless you're on the web or in the browser, then nope, you don't do that.

02:28 Instead, what you would do is you'd use this py-env section to express.

02:32 I depend on these packages, either just a URL to a wheel, a Python wheel,

02:37 or something that could be pip installed using micro pip.

02:40 That's gone.

02:41 It's now deprecated and will be taken away.

02:44 So now that's folded into the pyconfig section.

02:48 And there's a way to say packages are a list of packages.

02:51 And files that we're using is a list of paths.

02:54 And it's in these kind of places where you indicate what Python files you might write and import.

03:00 Because while you can write Python in HTML, just like JavaScript, you should do that very sparingly.

03:07 And you shouldn't just write your, you know, a thousand lines of Python, like inline.

03:10 That's not a great idea.

03:11 So you would link over to a set of Python files that you can run one of them and import others from that.

03:18 All right.

03:18 So pyenv going away, folded into pyconfig.

03:22 This is one of the things that's easy to fix.

03:23 But like I said, will stop working.

03:25 They've also changed the syntax of some events.

03:29 So you might have seen people on HTML elements like a paragraph or a div or a button.

03:34 It's a mouse over equals in some JavaScript function name, like a function call, either inline function or a function you've written.

03:43 In PyScript, there's a py dash event.

03:47 So there's a py dash mouse over and a py dash click type of thing.

03:52 And in here, you can just write arbitrary Python.

03:55 And unlike JavaScript, you can actually write arbitrary Python, multiline Python separated by semicolons.

04:03 Look at that.

04:03 Semicolons, they made it to Python.

04:05 You can write arbitrary Python.

04:07 It doesn't have to be a single function call.

04:08 Pretty cool, right?

04:09 It is pretty cool.

04:11 Python's starting to turn into JavaScript that is changing all the time.

04:15 Exactly.

04:16 Well, that's why the breaking changes.

04:17 No, just kidding.

04:18 That's the new project.

04:19 But don't let it become JavaScript.

04:22 I'm very excited that maybe it could supplant JavaScript to some degree.

04:25 There's some stuff about HTML escaping.

04:28 So you could do like print a string that will show up in the browser sometimes, or you can get it to go to the console.

04:37 But if you put like one is less than two, and that shows up in the browser, you know, that might get interpreted as an opening bracket instead of just a less than symbol.

04:47 All right.

04:47 So there's some fixes there, some stuff for logging.

04:50 The ability to run multiple runtimes.

04:53 So there's, when people usually do PyScript, they point at just a CDN version of PyScript, which points at a CDN version of Pyodide.

05:02 But you can, and easily can do, you can like download that, customize it, and put it in your static files and run it out of there.

05:12 You could possibly not even use Pyodide itself.

05:16 You could use, say, like MicroPython, potentially.

05:18 Or you could actually have maybe different versions of Pyodide running in different sections of your site, if you want it.

05:27 So different PyScript blocks, presumably even on the same page.

05:30 So a lot of flexibility about managing multiple runtimes.

05:34 Let's see a few other things.

05:36 There's also some major releases of Pyodide that's coming along.

05:39 And because it's built on top of Pyodide or runs on top of Pyodide, PyScript does, obviously the changes there are super important.

05:46 So some of the changes are that they broke, it used to be kind of like one huge namespace, and they broke that up into a bunch of pieces.

05:52 So you got to know about that.

05:54 But probably the most relevant for people is you used to have to do this thing where you would import from JavaScript some event and do like a proxy type thing to like hook.

06:06 An event, which wasn't terrible, but it was kind of like, well, are you still doing Python?

06:09 I don't know.

06:10 Right.

06:11 So they've written a bunch of event handlers or event sources in Pyodide FFI.wrappers.

06:18 So like add event listener, remove event listener, set timeout, set interval, clear interval.

06:23 And so now you can just import, say like add event listener, have a function, Python function, and then you just say add event listener on a tag on an event.

06:32 And here's your Python function.

06:33 That's awesome, right?

06:34 That is awesome.

06:35 Yeah.

06:35 Yeah.

06:36 So they've added these event handler sources that are straight Python and not interoperating with JavaScript more directly.

06:44 There's a bunch of things behind the scenes that will make it better, like that we don't necessarily as users care about.

06:49 But like in scripting is getting better.

06:51 They've got a whole testing scheme.

06:53 You might be interested in this, Brian, for your show.

06:57 They do integration tests with PyWrite.

06:59 They do TypeScript tests because a lot of the interaction bits are in TypeScript.

07:04 And they do that with Jest.

07:06 And then Python, the Python code gets tested with pytest.

07:09 That's an interesting mix, huh?

07:11 I guess just point out, we said PyWrite.

07:14 It's PlayWrite.

07:16 Yeah, I'm sorry.

07:16 I'm too much on the Py right now.

07:18 Yes, PlayWrite.

07:18 Thank you for keeping me honest.

07:20 Yeah.

07:21 But I'll do a famous pull request on them to try to get that pytest case all lowercase.

07:27 That'd be good.

07:28 Yeah, I'm not even going to use this project until I get fixed.

07:32 So some stuff on infrastructure.

07:36 There's new CI things that they're working on to make it better.

07:40 They're using type annotations.

07:42 And they're trying to synchronize TypeScript and PyScript type annotations to kind of keep the end-to-end across JavaScript, across Python accurate.

07:51 And a bunch of stuff that's coming, in particular, a lot of rethinking how async works, because JavaScript is already super asynchronous, but it just has one loop.

08:01 And if you hook your async Python into that, then is it really async?

08:05 It's a little bit complicated.

08:07 You can check out what they said there.

08:08 But otherwise, very exciting stuff.

08:10 And if you're doing PyScript, definitely check this out, because it's going to affect you.

08:14 Yeah, that's cool.

08:15 Well, let's give your voice a little bit of a break.

08:18 Yeah, I mean, too much Rocky Like a Hurricane stuff going on.

08:22 Yeah.

08:23 Well, I want to talk about decorators a little bit.

08:27 So I was actually on a – I sat in on a Boston, the Python Boston meetup group.

08:34 They're still – it's kind of neat.

08:37 They're still doing online, so it's not really Boston.

08:39 It's anybody can jump in and have fun there.

08:44 But we're talking about pytest, and Ned Batchelder was there and talking about coverage also.

08:51 And he was showing us some of the test code.

08:54 It was really fun, because he was showing us some of the test code within the coverage – the

08:59 test code that tests coverage by coverage.py.

09:03 And he was showing some things about using decorator shortcuts.

09:09 And then I was like, that's really cool.

09:12 I always forget to do that.

09:14 And so he wrote up this – I don't know if it's just for me, but he wrote up a blog post called decorator shortcuts.

09:22 And especially – I mean, I guess for a lot of stuff, we use decorators a lot in Python now.

09:26 And pytest also uses a lot of decorators.

09:32 Things like pytest mark parameterize or pytest mark skip or xfail.

09:39 Those are all decorators built in part of pytest.

09:43 And so the thing he wanted to show us is, like, as an example, he's got some tests that have to – that are either skipped or xfailed on certain Python versions.

09:54 So he's got a way to test a piece of code that only works on, say, like it doesn't work on PyPy.

10:03 Or it doesn't work on, like, Python 3.8 or before or something like that.

10:09 And so he has these fairly complex, like, version – like, xfail decorator sequences that he can take.

10:21 And instead of saying – and let's say he's actually filed – maybe there's an issue.

10:25 And he's actually filed an issue against PyPy, for instance.

10:28 But his tests are still failing.

10:31 He had an example where instead of just this whole big xfail blob with the environment – checking the environment version,

10:39 and having a reason and a link to the defect, he just shortcutted that to just, like, a single variable name or single name that says xfail PyPy3749 as an example.

10:55 Just a single thing.

10:56 And then when you're using it, instead of this whole big blob, you can just write at xfail.

11:04 Instead of, like, xfail – instead of saying, like, pytestMark xfail, you can have this specific xfail.

11:08 And then you get the reason printout and everything.

11:11 That's very clever.

11:12 Yeah.

11:13 Especially – I like it for this is there's – we were talking about how we don't like to leave xfails in for a long time.

11:21 But sometimes you're dependent on a different piece of software that you're not one of the maintainers.

11:26 In which case, what do you do with the failing test?

11:29 One of the things you can do is you can xfail it and link it to a defect report so you can keep watch of it.

11:37 But, yeah, having a way to just mark different tests with the same thing is pretty cool.

11:44 And then this really kind of relates to really a lot of things.

11:48 There's a lot of places where we use long, complex decorators that you can just assign to a variable and then use it later.

11:56 Yeah.

11:57 To put this decorator on a test function, you have to have – you specify a whole bunch of conditionals around the version.

12:02 And then the reason is a big, long string.

12:04 And if that's affecting 10 tests, you put that on 10 tests, it's all over the place.

12:10 You know, one of the things that you hear from people sometimes is like, well, I don't like unit testing because it's hard to maintain.

12:16 And I find that when people say that a lot, they kind of go into like this sort of – this mode where when they're writing test code,

12:24 they forget about things like trying to isolate change to one place.

12:28 And you would never write the same code 10 times in a real part of your app.

12:32 Why should you write it 10 times duplicate in a test?

12:35 Right?

12:36 Well, it's hard to maintain.

12:37 Well, it'd be hard to maintain if you did that in your regular code too.

12:40 Just – you don't do it there, so don't do it here.

12:42 And this is a cool technique to accomplish that, yeah.

12:44 Yeah, definitely.

12:46 And this is – this part of it isn't – it's also great because it's consistent.

12:51 It keeps – it'd be terrible if you were, you know, referencing this issue in three different places,

12:57 but only sometimes including the link and, you know, having some consistency is good.

13:03 So – Absolutely.

13:05 And there was some concerns.

13:07 Larry Hastings put up a concern about possibly not doing this for code that can – that is – that generates a single-use object,

13:18 like iterator or something like that.

13:21 But just don't do that.

13:23 But Larry has a workaround.

13:25 If you – you can do it a different way if you have something that acts like that.

13:30 I see.

13:31 Interesting.

13:31 Yeah.

13:32 There's a lot of turtles all the way down, like decorators of functions that return functions.

13:37 And so what we do is wrap that in a function to alleviate the – capture the closure.

13:42 Yeah.

13:43 It's fun.

13:43 But anyway.

13:44 Cool.

13:46 Excellent stuff.

13:49 Yeah.

13:49 Next up, our sponsor.

13:51 Yeah.

13:51 We have a sponsor.

13:52 Our sponsor this week is Microsoft for Startups, Founders Hub.

13:57 So Microsoft for Startups, Founders Hub provides all founders at any stage with free resources to help solve startup challenges.

14:04 The platform provides technology benefits, access to expert guidance and skilled resources, mentorship, networking connections, and a whole bunch more.

14:13 And unlike others in the industry, Microsoft for Startup, Founders Hub does not require the startup to be investor-backed or third-party validated or able to relocate to San Francisco for a short time.

14:26 So Founders Hub is truly open to all.

14:28 So what do you get?

14:29 You get free access to GitHub and Microsoft Cloud with the ability to unlock credits over time.

14:35 They've also partnered with other companies like OpenAI to provide services and discounts.

14:41 And Microsoft, through the Microsoft for Startup Founders Hub, becoming a founder is no longer about who you know.

14:48 You'll have access to their mentorship network, giving you access to a pool of hundreds of mentors across a range of disciplines, across areas like idea validation, fundraising, management, coaching, sales, marketing, maybe even testing.

15:01 Who knows?

15:02 You'll be able to book a one-on-one meeting with the mentors, many of whom are former founders themselves.

15:08 So make your ideas a reality today with the critical support you'll get from Microsoft for Startups Founders Hub.

15:14 And to join or just check it out, visit pythonbytes.fm/foundershub 2022.

15:21 The link is in the show notes.

15:23 And I know you can find this stuff on your own with Google or something.

15:27 But if you go through our link, it helps them know that you heard about them here.

15:33 So thanks.

15:34 Yeah.

15:34 Thanks, Microsoft, for supporting the show.

15:36 Brian, before we move on, audience feedback from Henry Schreiner.

15:40 For that exact example, talking about pytest and decorators, I'm not fond of making the test directory importable unless I have to.

15:47 A mark might be better.

15:48 What do you think?

15:49 A mark might be better.

15:50 I mean, they are marks.

15:52 So the marks are decorators.

15:54 Yeah.

15:55 Okay.

15:55 Cool.

15:56 What is next?

15:58 Another continuation of my theme here.

16:02 So Mark Madsen sent over a recommendation to talk about this.

16:06 Unrelated to the previous announcement, only in timing or origin.

16:13 So Panel, people probably have heard of HoloViz.

16:16 And Panel is related to that project.

16:18 It's an open source Python library.

16:21 It tells us you create custom interactive web apps and dashboards by connecting widgets, plots, images.

16:27 So people have heard of Streamlit.

16:30 They've heard of H2O Wave.

16:32 They've heard of Plotly Dash.

16:34 It's like in that category, right?

16:36 So you can put together a lot of interactive fun pieces.

16:39 So for example, here, if you go to the main website for Panel, you can see that there's like this graph.

16:45 As you hover over it, it's very interactive.

16:47 But you also have widgets to let you reevaluate how you compare all these things and just play with it live.

16:53 Right?

16:54 Kind of like it's a notebook, but it's not.

16:55 That's neat, right?

16:56 Yeah.

16:57 So traditionally, this has run in Jupyter Notebooks.

17:01 Or you can run it on like the Flask backend type of thing.

17:06 You can host it on your own stroker.

17:07 The news is not that.

17:09 This has been around for a while.

17:10 The news is that Panel now comes to Wasm via Pyodide and has PyScript integration.

17:19 That's pretty awesome.

17:20 That is pretty cool.

17:21 So in order to host it before, you have to either have a running notebook server or you had to set up your own separate web server and maintain that thing.

17:28 And all that goes with.

17:29 And now you can just put a little py-config in there.

17:33 And boom, when they interact with your data and they run it, it just happens client side.

17:38 No servers needed.

17:39 So let's talk about some of the things here.

17:41 You can automatically convert Panel applications to a Pyodide version.

17:47 A couple of flavors.

17:48 Reasons I'll explain in a minute.

17:50 Or you can convert to a PyScript-based app, which is pretty epic.

17:54 So you could embed a panel inside your Sphinx documentation just to some HTML, which is pretty nuts.

18:02 So there's this convert command, panel space convert on the CLI.

18:07 And you can tell it the two format from your regular panel code to convert it to a Pyodide.

18:14 This one is good if you want to have a single HTML file that you say, here's my HTML file.

18:21 Off it goes.

18:21 It's just no dependencies.

18:23 And then it runs there.

18:24 That's not as good as creating a Pyodide worker, which creates a JavaScript and HTML file that you've got to serve over more of a server.

18:33 Or you can even output a PyScript version where you can write additional PyScript code.

18:38 It's pretty epic.

18:39 And here you can see a little example.

18:41 This looks like standard XGBoost SKLearn code right here.

18:46 It does all its things.

18:48 Except for the end, you just say pn.column.

18:51 And here's your output right there.

18:55 And you put your little pipeline you created and maybe a head of a data frame to show up.

19:01 And there it goes.

19:02 So in order to run this, you would say panel convert the script to a Pyodide worker.

19:07 Output Pyodide.

19:09 Then you just run a server locally so that you can get to it.

19:12 You can pull in the JavaScript, open it up, and you get something that looks like this.

19:15 That's super interactive.

19:17 There you have machine learning in the browser.

19:19 That simple.

19:20 That's pretty cool.

19:21 The browser's JavaScript will take over the world.

19:24 It'll get smart and then take off.

19:26 So a couple of cool tips and tricks they recommend is you can do --auto reload.

19:32 So if you make changes to the file, it'll auto reload the browser.

19:35 So just as you edit, you can also add a panel dot convert --watch.

19:41 So if the source files change, it'll regenerate the script.

19:45 And then the script will get reloaded.

19:46 So you can chain those together, I believe.

19:48 But then there's a section on formats that actually describes what is the point of the different outputs,

19:55 like Pyodide versus Pyodide worker.

19:57 So the worker one says it generates an HTML file and JavaScript that runs better.

20:01 This is the most in a separate thread.

20:03 This is the most performing option, but it has to be running out of a server instead of just a file.

20:07 Worth noting here, PyScript generates an HTML file leveraging PyScript, produces standalone HTML files containing pyenv and PyScript tags with the dependencies.

20:19 It's basically a PyScript variant of the Pyodide one.

20:23 Well, guess what?

20:24 This might need a little update coming soon.

20:26 Py-DNV is not there anymore, so they can check that out.

20:30 I'm sure they're on top of it.

20:32 Yeah.

20:33 Final thing to note here that's pretty dope is progressive web apps.

20:37 So this comes with a --PWA option, which turns your, I'm pretty sure this is going to require the Pyodide worker variant,

20:47 because you need these worker things for progressive web apps.

20:51 But this means that you can install your app into, say, an iPad or install it like a desktop app and run it with cached offline data.

21:02 So, for example, let's see if I go to YouTube here.

21:05 I signed in.

21:07 No.

21:07 Good.

21:08 So, like, in Vivaldi, I can right-click on this, and it'll say install YouTube there.

21:13 So if you did that option for your panel app, you could right-click and say install panel.

21:17 And you might think, oh, well, that's silly.

21:20 Like, who cares about that?

21:21 Let's see if this let me do it, though, here.

21:23 Oh, this is live.

21:25 If you go to a lot of these, I just need some video.

21:28 I don't really care where it is.

21:28 A lot of these, you can come in and actually click download.

21:32 I guess you've got to be signed in, but if you have, like, a premium account or whatever, you can click download.

21:37 And that's only possible for YouTube installed as a PWA.

21:40 Because I think a lot of people feel like, oh, it just gives me an icon on my homepage.

21:43 But, like, there's actually different behaviors.

21:45 So you can get, like, offline videos on the PWA YouTube, whereas the web one, you can't.

21:51 And so on.

21:52 So anyway, that's the kind of benefits you would get if you would do your panels at PWA, which is just a command line option.

21:58 Interesting.

21:58 Cool.

21:59 Anyway, people check it out if they're interested in building dashboards, they're interested in PyScript and running in the browser using WebAssembly.

22:06 Here's a pretty awesome option.

22:07 Thanks, Mark, for sending this in.

22:09 Yeah, thanks a lot.

22:12 Did you know that Python 3.11 is coming right up?

22:16 It's got to be soon.

22:17 It's October.

22:18 There's not that much October left.

22:19 Yeah, but it was 3.8 when we got the walrus operator.

22:23 Do you realize it's been that long?

22:25 It seems like the walrus operator is still new.

22:28 But that's a long time, yeah.

22:29 Yeah, so...

22:31 It's like an adolescent walrus now, not even a baby walrus.

22:35 Yeah, exactly.

22:37 So I think it's time for people to embrace the walrus.

22:40 And so one of the things you can do is you can install Marco Gorelli's auto walrus, and it'll convert your code for you in places where you really should have used the walrus operator.

22:52 So, and this is good if you're supporting 3.8 and above.

22:57 And golly, I hope you're already up to 3.9 or 3.10 by now.

23:01 So there's this auto walrus.

23:05 I checked it out.

23:06 It's pretty simple.

23:07 It can run as a pre-commit hook, too, which is nice.

23:12 But you can run it on the command line, which that's what I did when I tried it.

23:17 You pip install auto-walrus.

23:19 So it's one word, but with a dash in the middle.

23:22 And then you have this application.

23:25 You can run it on a file.

23:26 And like we said, you can run it as a pre-commit hook as well, and it'll run on everything.

23:31 But you can...

23:33 And it just converts stuff.

23:34 So if you have things like...

23:35 Here's a simple example of n equals 10.

23:38 And then if n is greater than 3, do something.

23:41 And that converts...

23:44 The auto walrus will convert that to the walrus operator of if, you know, n colon equal 10 is greater than 3.

23:55 And I kind of like this being separate from other tools because some people just honestly haven't been...

24:00 Haven't came on board with this already.

24:03 You know, embrace the walrus sort of thing.

24:06 But it's a fun way to just try it out on your code and do a diff.

24:10 Get diff and see what it changed.

24:13 And maybe you like it.

24:14 Maybe it's a thing to do as a group code review thing to just talk to your team and find out if you want to change it this way or not.

24:22 Yeah.

24:23 And then this reminded me of something.

24:25 I'm like, we had something like this before, right?

24:28 And back in episode 82...

24:32 Wow.

24:33 That was in 2018.

24:34 We talked about Anthony Satili's Pi upgrade.

24:40 So...

24:41 And that's...

24:43 It's been a while.

24:43 So that's like four years ago.

24:45 So I went and took a look again.

24:47 And I would like people to try to check out Pi upgrade too.

24:50 Because there's a whole...

24:51 It's moved on.

24:53 So it's not just...

24:54 We recommended Pi upgrade for things like upgrading from two to three sort of thing.

24:59 Was that back in the controversial legacy Python days?

25:02 Yeah.

25:03 So there's...

25:05 And there's always times to go and revisit old scripts and old applications that you're still maintaining.

25:10 And going, well, we don't really want to support the old Python.

25:14 But our code server looks like the old Python.

25:17 So let's take a look at some of this stuff.

25:19 And it'll do things like, you know, the set literal.

25:23 Some of the old things of...

25:25 And doing comprehensions for you.

25:28 And better...

25:30 Comprehensions are cleaner looking.

25:32 And then...

25:33 But there's also like different print styles.

25:35 But one of the things I wanted to point out is if you go to the readme, you got to scroll all the way down.

25:40 Or at least halfway down.

25:41 And you get things like the 3.6 plus.

25:43 So there's these plus options.

25:46 So you can say if you're running 3.6 or above, run that.

25:50 But you also want to do...

25:51 Like let's just go all the way down to like 3.7 plus.

25:54 And there was a kind of a new way to run subprocess, for instance.

25:59 But you're...

26:00 I mean...

26:01 And it just finds some of these things and just changes it for you.

26:04 So it's kind of cool.

26:05 Some of the things you may not have remembered.

26:07 The 3.8 plus the LRU cache.

26:12 You used to have to do the LRU cache and call it as a function for your decorator.

26:18 But now you don't have to do the PRINs.

26:20 So just some cleanup like that.

26:22 It's just nice.

26:24 I try to run this every once in a while.

26:27 And yeah, I guess public service announcement for this cool little project.

26:32 That is a cool project.

26:33 And going through this huge long readme and looking at like as it gets later and later in Python

26:38 versions, it's kind of like a...

26:40 Here are just a bunch of examples of how Python has changed over the last few years.

26:43 Yeah.

26:44 Ooh, neat.

26:45 It has like 604 type rewrites.

26:48 It'll rewrite the union operator to the bar operator.

26:53 That's in 3.10 plus.

26:55 That's nice.

26:55 Yeah.

26:56 Well, we got 3.11 plus coming soon.

26:59 Yeah.

27:00 Yeah.

27:00 That'll be fun.

27:01 Awesome.

27:02 Well, that's our items, right?

27:04 Got any extras?

27:05 You know, I was going to have an extra, but I'm going to save that for later.

27:11 So no, I don't.

27:12 Do you have any extras?

27:12 No extras.

27:15 But I have a joke.

27:15 I do a quick follow-up to this though.

27:17 This is a hint of what's coming next week.

27:20 I'm going to talk.

27:21 I think it's next week.

27:22 I'm going to cover this.

27:23 Refurb.

27:23 Have you seen Refurb?

27:24 I don't think so.

27:26 Refurb is a similar one that like will go through and give you recommendations of here's

27:29 the most modern way to do your thing.

27:31 So like if you said, you know, if value is in bracket XYZ, it's like, you know, it's a

27:37 little less efficient than like why make a mutable list when you could make it a tuple.

27:42 It's a little more efficient just to create the tuple.

27:45 So if value is in parenthesis, it'll suggest you change a parenthesis or suggest using some

27:52 path lib operations instead of with open operations.

27:55 Like instead of a context manager with open, do a bunch of stuff.

27:58 You can just do path of thing dot read text.

28:00 You don't need to do the context manager.

28:02 Just bam, there it is.

28:03 A bunch of cool stuff like that.

28:05 So anyway, that one more.

28:07 And then also Flint.

28:08 I've talked about Flint.

28:09 I love Flint.

28:10 Super straightforward.

28:11 It brings one of the most beloved things you can do for upgrading your Python is convert

28:17 all your variations of string formatting to f-strings just across a whole directory of

28:22 Python files.

28:22 Cool.

28:23 A lot of different things to be running together, but are you ready for our joke?

28:26 I am.

28:27 You had the comment about bring back the walrus or something.

28:32 I feel like that could be a cool t-shirt, right?

28:35 Yeah.

28:35 Yeah, absolutely.

28:36 So I came across this place a little while ago.

28:39 I don't have any particular one to recommend here, but this place that has like funny, geeky

28:46 t-shirts.

28:46 So I thought I'd just pull a couple of these up and see what you think about them.

28:51 So some of them are good.

28:53 I like the first one, the Mordor.

28:54 The Mordor fun run.

28:57 One does not simply walk into Middle Earth.

29:01 You have some for our data science friends out there.

29:04 It has a graph of two things that are very similar.

29:07 One is shark attacks.

29:10 The other is ice cream cone sales.

29:12 And it says correlation does not imply causation.

29:15 Apparently ice cream sales and shark attacks are closely correlated because it's warm.

29:20 You go in the water.

29:20 It probably doesn't cause shark attacks.

29:23 It might.

29:25 It might.

29:25 If you are more into math, you have the distance raptor divided by time raptor is the velociraptor.

29:33 But there's some really good programming ones in here as well.

29:39 Like this one, for example, check this out.

29:40 Go outside.

29:41 The graphics are amazing.

29:43 And the picture of the shirt is like a super low bit rate, like graphics.

29:47 Here's a good one.

29:52 Some lab person pouring like beakers of clearly poisonous green stuff.

29:57 It says, forget lab safety.

29:58 I want superpowers.

30:02 Oh, boy.

30:02 What about the, what do you think of this one, Brian?

30:04 Here, the forecast for Alderaan.

30:06 So remember, Alderaan is the home of Princess Leia that was blown up by the Death Star and Star Wars.

30:14 And it says five day forecast, Alderaan.

30:16 Monday, 72 and cloudy.

30:18 Tuesday, 74.

30:19 Wednesday, 15,000 degrees.

30:21 No Thursday or Friday.

30:23 It's kind of mean, but it's also kind of awesome.

30:26 Yeah.

30:27 Those are good.

30:28 Yeah.

30:29 This is me.

30:30 We see if I can find one more, one more programming one.

30:34 Oh, yeah.

30:35 Let's see.

30:37 Here's some good ones.

30:39 One, it has a floppy disk.

30:41 It says, kids today have no idea what this is.

30:44 And then this one here, Brian, this is the last one.

30:48 It's somebody holding a CD going into a drive.

30:51 And it just says, never forget.

30:53 Never forget the CDs.

30:55 Yeah.

30:56 CD drive.

30:57 I still love that old joke of a person calls into IT help desk and says, I need some help because my cup holder's broken.

31:07 Yeah.

31:09 I just went in and spilled this drink all over me.

31:11 Come on, man.

31:12 You guys got to get a safe fix.

31:14 Yeah.

31:17 So you could spend a lot of time on this page.

31:19 I'm not necessarily suggesting you get a shirt here or anything, but it's pretty awesome.

31:23 Well, it makes me miss ThinkGeek.

31:25 ThinkGeek should have never folded.

31:28 But we have other people coming up with good humorous shirts.

31:32 So that's good.

31:33 Yeah.

31:34 Houston, we have dibs.

31:35 Putting a flag on the moon.

31:36 Dibs on the moon.

31:41 Got it.

31:43 So a more serious, a couple quick follow-up here.

31:48 Marco Garelli, from the project that you talked about, the Auto Auris, says, yeah, I love Pi Upgrade.

31:54 And Will McGugan.

31:55 Hey, guys.

31:56 We could use the Pi Upgrade because Rich is dropping support for 3.6.

32:02 So just clean it up.

32:03 Yeah.

32:03 And then I want to follow up with the first thing I was talking about, about the decorators.

32:11 So Henry Schreiner said, oh, I think I got the wrong one.

32:15 But for that example, I'm not fond of making the test directory importable unless I have to.

32:21 A mark might be better.

32:23 And I guess I brushed that off too quickly.

32:31 If I were to put a bunch of these, like if I had a project-wide decorators that I wanted to use, I don't know what the best way to do that would be.

32:39 It might be a non-test file that I would import.

32:41 I'll have to play with it.

32:43 So thanks for Henry for bringing that up.

32:45 I'm not quite sure how to deal with that problem.

32:47 Indeed.

32:48 All right.

32:49 Well, should we call it a week?

32:51 Let's call it.

32:52 All right.

32:54 Thanks everybody for showing up.

32:55 We'll talk to you next week.

Back to show page