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


Transcript #248: while True: stand up, sit down

Return to episode page view on github
Recorded on Thursday, Sep 2, 2021.

00:00 Hey there, thanks for listening.

00:01 Before we jump into this episode, I just want to remind you that this episode is brought to you by us over at TalkBython Training, and Brian through his pytest book.

00:10 So if you want to get hands on and learn something with Python, be sure to consider our courses over at TalkBython Training.

00:17 Visit them via pythonbytes.fm/courses.

00:21 And if you're looking to do testing and get better with pytest, check out Brian's book at pythonbytes.fm/pytest.

00:28 Enjoy the episode.

00:29 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 248 recorded September 1st, 2021. Gasp, it's summer over.

00:42 I'm Michael Kennedy.

00:43 >> I'm Brian Okken.

00:44 >> I'm Paul Everett.

00:45 >> Yay, Paul Everett's here.

00:46 >> Yay.

00:47 >> Welcome, Paul.

00:48 >> Joy to be here. Long time listener, first time caller.

00:51 >> Yeah. I think you made an appearance in the previous show in the live chat, but now you're --

00:56 >> Oh, yes, the live -- yeah, true. The live chat.

00:57 or possibly a talk Python, I can't remember.

00:58 It all blurs together.

00:59 - I wasn't as prepared as this one.

01:01 - No, now you're on the big stage.

01:03 So thank you for being here.

01:05 You know, tell people about the things that you've been up to or what you're doing or who you are before we jump into our first topic.

01:12 - I'm developer advocate at JetBrains for Python and web, which means PyCharm and WebStorm.

01:17 What a great gig, love my job.

01:21 I always joke that they should be, I should be paying them, but don't tell them I said that.

01:25 And I'm just embarrassed that here I am on Python Bytes and I didn't get a haircut in time.

01:32 I know this is a podcast, but there's a video version.

01:35 - That's right.

01:36 - Looking at Brian rocking the do, I feel like I should have been better prepared.

01:40 - Yeah, Brian and I have alternate philosophies, I guess.

01:43 I've got like the knight's neat hair and Brian's just embracing it.

01:47 And yeah, I would do that too, except for mine just looks like a giant poofy thing on top of my head, it doesn't look cool.

01:52 So yeah, not so much.

01:54 - Oh, I wanna see that.

01:55 - Yeah, it's amazingly bad, yeah.

01:57 I've tried it, not amazing.

02:00 All right, but you probably have something amazing to tell us about, right?

02:03 - Well, I do.

02:04 Actually, so this is an interesting article.

02:08 I wanna talk about both Adders and Pydantic because we've talked about both of them on the show and they're both great libraries, I think.

02:17 And so there's this article that I came across called "Why I Use Adders Instead of Pydantic." There's actually a lot more in here than just that.

02:26 It was an interesting read.

02:28 Starts out right off the bat, talking about basically one of the things that a lot of people think about with adders is, don't we have data classes?

02:38 Do we need adders anymore?

02:40 Starts out not talking about Pydantic, but talking about data classes.

02:47 That data classes really came about as a subset of the Adders functionality.

02:53 It's really pretty easy to go back to using Adders.

02:57 If you're familiar with data classes, it should be easy.

03:00 Actually, there's a lot of reasons to use Adders instead.

03:04 For one, they're just faster, which I didn't know that they were faster.

03:09 But there's some examples about a lot of the boilerplate stuff that goes into data classes that we don't really think about.

03:17 But Adders is pretty tight.

03:20 Also, Adders has more features and has some validation code that isn't around for data classes.

03:28 That's interesting. Then getting into talking about Pydantic.

03:34 I think of Adders as like data classes, but it does more.

03:40 This author summarized Adders as a library for generating the boring parts of writing classes.

03:48 >> Like the hash, the equals, the not equals, that kind of stuff, right?

03:52 >> Yeah.

03:53 >> Property.

03:53 >> Also, like throwing in some validation if you want.

03:56 So you can opt in.

03:57 So putting in some validation, you can set that up.

04:01 There's a lot of stuff that Adders does.

04:04 I mean, it's a lot more than that.

04:05 It's a pretty full library also.

04:07 But what you get with Bidantic is you get that with the classes that Bidantic provides, but you also have the validation library and structuring and unstructuring, and conversion to and from a different type, like say JSON, into a pedantic class.

04:29 All these components really are with adders.

04:33 You can do all of that.

04:35 You opt in instead of having to opt out of it.

04:40 It's a really interesting take on that.

04:43 I thought of it as I've got a great screwdriver, I've got great knives, but I don't think of my Swiss Army knife as anything, it's just that it has everything.

04:56 I don't think it was that harsh of a comparison, but we also think about that with Django and Flask, where Flask is build up your own framework, and Django has a lot of built-ins already.

05:08 It isn't even that simple.

05:10 There was an example of some of the validation that is built into Pydantic that just seems wrong.

05:20 The example was, if you've got a list of 1,000 integers, do you really want Pydantic to go and you pass in a list of integers?

05:29 You want to make sure it's passing in a list, but do you want it to go through and make sure absolutely all 1,000 elements is an integer?

05:37 You might, in which case you're in luck because that's what it does.

05:41 But if you don't want to do that because that's just too much time, you're out of luck.

05:47 Well, you also got to remember the origins of Pydantic were about accepting input from arbitrary things on the internet.

05:56 Oh, yeah.

05:57 And when your goal is like, I'm accepting unstructured data from random endpoint, on a random endpoint, like you need a different level of integrity than I loaded this off of a JSON file and I know the app created it, it's not going to be broken.

06:11 It's going to be self-consistent, at least in the fact that the data types are probably still consistent.

06:17 It's probably a when to use which sort of thing as well.

06:21 >> Yeah. That's the generated adders class and the generated pedantic class.

06:27 It's around validation.

06:30 Yeah, it is interesting.

06:32 The other aspect is making sure that data is validated when it's set, not just when it's created.

06:41 I think I got lost here, but correct me if I'm wrong, Paul.

06:45 But I think it's that Pydantic only validates on creation, whereas you can set adders to be validating on setting values as well.

06:54 But I could be wrong.

06:56 >> I believe you're right. I went and looked up a ticket in Pydantic.

07:00 I didn't read the whole thing about it, but these are hard conversations.

07:05 There's no free lunch.

07:07 This article I thought was a fair treatment about the topic.

07:12 >> Yeah. The conversion bit was a little interesting.

07:15 For instance, date conversion.

07:17 If you pass in datetime to a pedantic model, pedantic already has datetime conversions built in, so it'll automatically convert it.

07:26 But if you are using like Pendulum, which is a subclass of date/time, you're going to get a wrong conversion.

07:37 It's just going to do it wrong because it'll assume it's a date/time and not a pendulum object.

07:43 That's interesting. Yeah, anyway, definitely something to think about of the build your own versus having it all in one.

07:52 But I definitely think there's places for both.

07:55 Like Michael said, especially with input validation on the web. If you know what you're doing, definitely I think maybe you could roll your own or use all these adders and other tools.

08:06 But if you're just sort of playing at it and you're just getting started, then why not try PyTandic? It's a great place for that.

08:14 Yeah, the other thing is about the open API specification stuff with PyTandic, where if you just use them and you just say, I'm using this, it'll like automatically generate the documentation, which is a big bonus.

08:25 It's interesting with the release of SQL model, it's like you can kind of feel like Pydantic is its own little mini framework dispatcher thingy with hook points that you can plug into and almost treat as its own little API surface for gluing things together.

08:46 Yeah, it's the data exchange bit, pretty interesting.

08:49 Brandon, Brandon out in the live stream says, I think it comes down to using the right tool for the right job, which is Yeah. And how you opened it, right, Brian?

08:56 Yeah.

08:57 All right. So we all work with the terminal every now and then, right?

09:01 Every day.

09:02 You might be working with the command prompt if you're on Windows, but I strongly encourage you not to do that.

09:08 You should be switching over to the new Microsoft terminal with like, oh, my Posh shell and then you'll be in the terminal world as well.

09:17 So DunderDan on Twitter, send us a recommendation, which I want to cover called McFly, which I love the name.

09:25 So what is it?

09:26 It is a bit of Rust code that extension for your terminal.

09:32 Super easy to install, like you can brew install it and other types of install it.

09:36 And basically what it does is it lets you fly through your shell history.

09:40 Okay. So depending on the shell you use, you may use this a lot or you may use this a little.

09:44 You can hit control R in your terminal, and it brings up a reverse history search.

09:51 So like if you knew you type something to do with git and it had to do with this repo, you could hit control R and like type parts of the repo name and that would start to auto-complete those commands.

10:02 There's a couple of things that are kind of a bummer about that though.

10:05 One is maybe the biggest one is you only see one of those at a time, right?

10:10 So if I go and say, show me my history, I get a line and then that is the closest, most recent match to what I type.

10:16 Well, what I often might want is like, it's kind of like a git clone, but which one was it and I want to see which ones of those are that like that UI is not fantastic.

10:27 So imagine if you could type, say, git clone and then hit control R and it gave you like a UI in the terminal that you could scroll through and pick and then you could see what else to type a little bit more. That's McFly. So it's pretty awesome in that regard, but it also uses a little bit of AI, if you will, a little neural network and some context awareness to help filter and order that, I guess, probably sort is probably the biggest thing.

10:55 It'll say, well, what, you know, we're searching for this, but usually when you're in this folder, you're often using this, this version of that command. But if you're in a different folder, you're doing a different version of get. And so it'll try to filter your history based on the context of where you are. What do you all think? I think, I think it looks pretty cool.

11:14 I was luckily, I don't know why anybody would use the built in Windows command prompt. So I'm even on Windows, I'm using bash.

11:22 But--

11:24 Oh, my PowerShell is pretty sweet in the new terminal.

11:28 Carry on. Sorry, don't mean to derail it.

11:31 Anyway, searching history with the VI mode is pretty easy in bash.

11:35 But I was glad to see that this isn't just for your command prompt or posh or anything.

11:42 You can use this with Z shell and fish and bash too.

11:47 Yeah, it works in a lot of them.

11:48 And so I found it to be quite neat.

11:51 So let's see, I'll run through some of the features.

11:53 So you just, it rebinds control R, which is kind of nice, but one of the things, it'll store your history in a little local SQLite database, so it can do more queries and more interesting stuff, have richer information on it, but it also like injects the commands that it sees into your regular shell history.

12:10 So if you stop using it, your shell history for say Z shell is still totally good.

12:15 That's pretty nice.

12:16 I will say that I know you had Brett on recently.

12:20 And so the rustification of Python bytes appears to be complete at this point.

12:26 You can't go anywhere without bumping into rust.

12:28 - I know you keep bumping into it.

12:29 It is quite interesting here.

12:31 - And my other comment is that, I hate to say it, but I think the three of us were, we've been around so long, we were pair programming with Moses.

12:40 And the idea that I really needed a small neural network for my shell.

12:46 That's a tough one.

12:47 Yeah.

12:47 It's interesting.

12:48 Right.

12:48 But I do think, I mean, I do think it adds quite a bit of interesting, extensions for this stuff.

12:54 Like it's a really cool way to do, you know, I use, oh my Z shell.

12:59 So if I wanted like SSH somewhere, I could type SSH and just start hitting up arrow and it's like a beautiful history map.

13:05 Like I never use control R because there's a better one.

13:07 I got to make that jump.

13:08 One of these.

13:09 Yeah.

13:09 It's so, it's so good.

13:10 but sometimes I don't remember exactly what it is, or there's like a lot of them.

13:16 And so with this one, it'll give you that drop down list that fills the whole screen so you can jump through them.

13:22 You can also delete, you're like this one I did once but I never want to actually don't even want it in my history.

13:26 You can delete it from your history, which is kind of nice.

13:29 And then also let's go through some of the other things.

13:32 So yeah, so in terms of prioritization, you know, that little neural says it takes into consideration the directory where you ran the command, what you typed before the command.

13:43 So if you did a get branch and then a checkout, I don't know, maybe that means something or I don't know, whatever.

13:49 But like the series of commands that preceded it influence what it suggests and how it orders it, how often you run it, when you last ran it, what you've selected in it as it's dropped down.

14:00 And also it's exit status.

14:03 So if you ran a command, but the command failed, like it won't auto suggest that command again, 'cause that one's the broken one.

14:09 You know what I mean?

14:10 Things like that.

14:11 There's a lot of cool stuff.

14:11 - Oh, that's cool.

14:12 And then I got one for you, Brian, down here.

14:14 So it's easy to install this, like, you know, brew install or where's the, probably an app you get installed or something.

14:21 Anyway, if I go down here, there's all sorts of ways to install it.

14:25 But here we are.

14:27 Vim key bindings, Brian.

14:30 - Yes, okay.

14:31 - So, okay, so you have Vim key bindings, which is by default, it uses Emacs.

14:35 It definitely reminded me of like just firing up Emacs, but for the shell, which was kind of nice.

14:41 The other thing that I like about it, I haven't turned this on yet, is fuzzy searching.

14:45 So sometimes I'll be like, "Ah, there's this command. I think it was this." But if you get it wrong, then it's like you get zero help, right?

14:52 If you get one character wrong. But this one is, if you get close, can you get close and we'll give you some autocomplete on that? That's pretty cool.

14:59 Yeah, that's great. Because you might be searching for a file name or something like that.

15:03 Yeah, yeah, exactly.

15:05 Did you see that? There was an XKCD, I think, or some other comic of somebody.

15:11 Now it's a different one, but somebody scrolling through their history for like an hour to get LS.

15:16 Yes.

15:17 [laughter]

15:19 Now I'm definitely going to try this out. This is pretty good.

15:22 Can you scroll?

15:23 Yeah.

15:24 Oh, you're going on the XKCD.

15:25 No, sorry.

15:26 Can you scroll up to the commits?

15:28 Number of commits?

15:29 Yeah, 350.

15:30 Yeah, this has the look of a project that's been refined, doesn't it?

15:34 Yeah. Yeah, it does.

15:35 I don't know quite how long it's been around, but yeah, it looks like The oldest super obvious one is 14 months.

15:43 Yeah, it's continuous integration.

15:46 It was last configured 14 months ago, let's say.

15:48 But yeah, this is--

15:49 >> No, it's the docs. The docs were two years ago.

15:51 >> Okay. The docs, there you go.

15:53 I think this is nice. I wasn't sure I would want to use it.

15:56 I'm like, "Oh, this is interesting." People might-- then I installed it.

15:58 I'm like, "Oh my God, this is pretty cool. I like it." >> All the cool stuff I like in Python, like pyenv and pipx and things like that, they all have a section about using this with Fish.

16:10 And so I'm always taunted with my lack of foo when it comes to terminals.

16:16 Yeah, I made the switch to Zshell.

16:19 Oh, my Zshell, I'm not looking back. Love it.

16:22 Alright, Patrick Povil out in the live stream says, McFly seems really interesting. I'm using Zshell for a month now and always thought the Ctrl+R search lacks features compared to other plugins.

16:31 For sure. Absolutely.

16:32 And then David Pochan out there says, you covered that LS joke in the show.

16:37 Yeah, it's beautiful. I love that one.

16:39 It's been a couple of years, I think, but it was a good one.

16:41 >> Well, we don't have a joke history command.

16:44 >> Yeah. Oh, McLaugh.

16:46 He's writing McLaugh.

16:48 Something we never cover on the show is textual.

16:53 Why don't you tell us about that, Paul?

16:54 >> Sure. Switching over to me.

16:57 Yep, we got me. I think it was episode 241 when you had Brett on and Brian led with Will McGugan talking about Rich.

17:08 And I'll quote Brian because it was funny then and it's funny now.

17:11 "How can I not have heard of it?

17:14 I'm a fan of the podcast and Brian loves this tool." So I'm going to go back to the well with the thing that was spun out of Rich at that time, Textual, which has been covered, but I want to talk about a particular aspect of it that was kind of interesting to me as a pattern.

17:29 And then have a little debate where the two of you tell me that I'm wrong and really ancient about this.

17:37 So I've traditionally been against the convention over configuration camp in the world of Python.

17:46 I come out of kind of the ZOPE tradition, the Pyramid tradition.

17:49 Pyramid is like, "Oh, yeah, well, here's a configurator object, and it does 15 trillion things that you really ought to care about but don't." Because Chris McDonough has really great design sense, kind of Goldilocks, knows exactly what to put in and leave out.

18:05 I just, that whole worldview fits into my head.

18:08 And so I have this dislike about magic names, magic file names, magic variable names, can't auto-complete them, can't refactor, can't navigate.

18:18 If you can't memorize it and keep it all in your head, you know, and Python is explicit over implicit, blah, blah, blah.

18:25 I prefer like actual symbols that smart editors can operate on and not have like is a little bit that's going on with data classes right now.

18:35 Each individual tool having to wire up special support for that template language or that this, that, or the other thing to look for these magic hand waves.

18:44 But Will had this thread, and actually I should bring the thread up.

18:49 Will had this thread on Twitter, which made me feel, A, like I was a little bit wrong, and B, like he had solved some of the issues that I had with it.

19:02 So what he wanted to do was remove some boilerplate.

19:06 And in this, he gave some examples about before and after.

19:12 Here's a screenshot of it.

19:14 So that's before, and you see, like in here, watch how much this changes when you go to this.

19:22 So kind of the noise, the ceremony, a lot of the stuff was reduced.

19:28 Okay.

19:29 Now, anybody can look at this and say, "Wow, that's great." If you're optimizing for writing code, if you're optimizing for reading code, and you want to walk back up to this later and know that there are some special semantics that, you know, if the name starts with these three things, then the next thing is kind of a thing that is, etc.

19:50 And so I worry about those kinds of things, but he had done it in a way where my pie would still help you some.

19:58 And one of the innovations he had that I felt like, let's see, do you see me on Twitter?

20:06 No, you don't, because I'm in the wrong window.

20:09 Sorry about that.

20:09 OK, my apologies.

20:11 So in the screenshot, you see a before and after.

20:14 Brian, you see that? Yeah.

20:16 All right. Good. Before and after.

20:19 And so he's talking about boilerplate removal in this thread and some of the decisions such as like this.

20:27 For any of you that do type annotations, type hints, you'll look at this and you will say, "Oh, goodness, the type hint went away." This is actually a perfect example.

20:40 And you look at this and you think, "I just lost the typing information and I believe in type hinting." Well, not really because it can be inferred, it can be deduced.

20:49 Right, so for people listening, the example is you've got like a variable colon type equals Sorry, yes, this is a podcast.

20:55 Instantiate the type versus just drop the type annotation on the variable.

21:00 But when you're allocating up the object right there, like all the editors in my pyre are like, you know what?

21:07 Thing equals new object.

21:09 That's right.

21:09 It could be that object.

21:11 Yeah, and in these like titantic battles about type pinning, we forget that, well, you don't have to do all that typing all the time.

21:19 Python and type checkers, static analysis can figure this kind of stuff out.

21:23 So I looked at that, I was pretty, I was probably kind of seduced by that.

21:27 But let me ask the two of you, maybe the audience as well.

21:31 Do you think that three months from now, if you walked up to your textual application, would you be able to remember that he had done these things and that the right hand side was telling you about the left hand side.

21:45 In order to save a little bit of typing, did I lose a little bit down the road and have to load up my future self?

21:53 What do you think about that?

21:54 Brian?

21:55 Well, I'll tell you what I think.

21:58 Is there a separation of where this happens?

22:01 Like on the example that you're showing here, like object or variable equals new object.

22:06 I never need help with that.

22:08 I get super clear what that type is all the time.

22:10 Where it becomes not so obvious to me is where I've got like a class or something and it's got a field and then I'm, I'm creating that object and passing it in.

22:22 If my PI could still tell me, oh, this, this thing is one of these because the only time you ever use it, it's always passing this type.

22:29 But that's a separate file and I'm not looking at it side by side.

22:32 Then to me that like starts to add additional work for me to keep track of in my mind.

22:38 The other one I would say is the auto-complete test.

22:42 If I'm working with thing, I say variable dot and it goes zoom, there's the list of things.

22:47 There's a good chance I don't care about anything else.

22:49 Right, like did it auto-complete the thing and did it tell me if I put the wrong property field, whatever on it because it knows what that list is.

22:57 And if the magic name changes later, will I get a red squiggle?

23:01 Yes, exactly.

23:01 Will the editor know that it was broken and will it help me write it so I don't have to look at the docs, I don't have to go to the source.

23:08 I just use variable dot and I just keep rocking until I really need to understand something.

23:13 Yeah.

23:13 I would say that that's where I come down on it.

23:17 The third thing is, if this is not relevant here necessarily, but if you're doing something like SQLAlchemy or Mongo Engine or Django ORM, so often what they do is they have like two flavors of the thing.

23:30 I'm creating a class.

23:31 The class has a field.

23:32 It's called email.

23:33 Oh wait, no.

23:34 What is it?

23:34 It's being set to a new Mongo engine field of type string that has a regular expression on it.

23:42 Wait, that's not what, that's not what I get at runtime.

23:44 At runtime, I get a string at code time.

23:47 I get this.

23:48 So for those, I will say field colon type is string equals Mongo field is a Mongo string or whatever, or SQL, can you call them of type string?

23:59 Because I want it, I want it to be explicit that it's not really what it says there, because often the editors will like give you like column information, which doesn't make any sense.

24:08 Anyway, that's a long answer, but I gave Brian some time to think about his position here.

24:12 I'm actually just, I'm very impressed with Will's design decisions on a lot of things. And I am, like, there may be some magic hidden in there, but I would rather have less code to look at. So, less code to look at means less things to get wrong, as far as I'm concerned.

24:34 I am coming down with you on this one.

24:38 I've been working for a long time on kind of a long project about static analysis and Python templating that is driven by type hints.

24:48 And looking at what he's done has made me step back and think, wow, there's some things you can do without throwing out type hinting that improves the readability and removes the boilerplate while keeping people on the rails.

25:02 Back to what you said about Will's design decisions, looking inside the code of Textual is really fascinating to me.

25:10 Fascinating enough that first, today Will announced that he is changing his job status so that he can work for the next three months on open source completely rather than at night and is looking to meet a target for GitHub sponsorship.

25:26 So let's all go out there and sponsor him so we can get these delicious looking treats that he keeps giving to us But second I'm interested enough that I want to join the freaking project and learn from him. I need a reactive system He's got one. Yeah, I wouldn't even know how to write a test for it and he's got that too So I'm with you on that I love the way he writes his code the way he talks about his thinking in public while being a gentle and encouraging public figure.

25:58 - Yeah, well said.

26:00 - Absolutely.

26:01 Well, very, very cool stuff.

26:02 There's a lot of neat things coming out of there.

26:04 I think a lot of people's reactions are like astonishment.

26:07 Like, wait, that's a terminal?

26:08 That's insane that it does that.

26:10 - Yeah.

26:12 Onto the next.

26:14 Speaking of testing, have either of you ever used DocTest?

26:20 Paul?

26:21 - Yes, I have.

26:22 So I, way back when, when I started blogging about testing, I thought it'd be fun to compare the test frameworks because I wrote my own, it wasn't fun.

26:34 So I looked at unit test, I looked at doc test, I looked at pytest and nose also.

26:40 And I actually thought, you know, maybe just, I didn't think it would go very far, but I tried to use Doctest as a end-to-end test tool.

26:54 It was difficult. There's still some cool things about Doctest.

27:00 If people are unclear what Doctest is, Doctest is a package that's built into Python that you can write.

27:07 You can use it by saying Python-M Doctest and point it at a file, one of your source files.

27:14 Within your doc strings, If you've got things that are like the three, I'll see if I've got it here.

27:21 The three arrows or something like the prompt, the Python REPL, and you can type some examples in there, and Doctest makes sure that the output really matches what you said.

27:33 Doctest will go through and make sure your code examples within your code actually work.

27:38 This is a cool idea in principle.

27:41 In practice, it's very painful.

27:43 A lot of the pain points come around, "Well, I forgot to import anything." So you have to include the imports in there.

27:50 Or, "I forgot to," there's a lot of stuff that can go wrong.

27:54 Now, pytest adds some things, you can run DocTest from pytest, it's pretty cool.

28:00 What we're talking about now is a new project or a project new to me called XDocTest.

28:06 XDocTest, it's got a whole bunch of cool features.

28:11 One of the things is, doc test is a regexplate-based thing.

28:14 It pulls out the string, finds the code, runs it, looks at the output, make sure they match.

28:20 XDocTest uses the source tree thing.

28:26 >> Abstract syntax tree?

28:28 >> That's it, abstract syntax tree.

28:31 It's actually parsing it better, and there's a whole bunch of cool stuff you get with that.

28:37 There's some highlights in there.

28:41 Like one of the things is string continuation was painful because you had to include the angle bracket things.

28:49 You don't have to do that with XDocTest.

28:51 The thing that I love the most though is one of the defaults in DocTest is it does not do white-space normalization.

29:01 You can turn it on, but it doesn't do it by default.

29:04 XDocTest by default does whitespace normalization.

29:08 What that means is, if in my code I cut and pasted stuff and added like a tab or a space at the end of my string, DocTest will fail that because it's like, "Oh, that string is not the same as whitespace at the end." I don't care about the whitespace at the end.

29:26 One of the things that XDocTest just fixes that right off the bat.

29:30 It's going to be way more pleasant just to work with.

29:32 But there's a whole bunch of other cool features of this that it brought in.

29:37 It has a more sane skip syntax, although they had to read it for a while.

29:42 You have to say plus skip to start the skipping, and then minus skip to turn it off.

29:48 Yeah, anyway, but it's pretty neat and flexible.

29:52 I think if you're going to start out trying to do doc test stuff, I would totally use xdoctest.

29:58 Plus it has a built-in pytest support.

30:00 If you have it installed, you can say pytest --xdoctest and run it on your code, it'll run fine.

30:07 >> Yeah, very nice. Paul, you've done-

30:09 >> You are two for two on predicting what I was going to talk about.

30:13 What I really want to hear you do is say abstract syntax tree in a daffy duck voice.

30:19 >> No. You.

30:23 >> No way. That'll be in the bonus track.

30:25 >> Brett Cannon made us sing a song from like Ren and Stimpy or something like that.

30:31 >> Ren and Stimpy.

30:32 >> Was it that? No, it was Pinky and the Brain.

30:35 >> Pinky and the Brain.

30:36 >> It's all from the same general genre and era.

30:40 >> We should do a Ren and Stimpy skit sometime. That would be fun.

30:43 >> God, Ren and Stimpy was awesome.

30:46 >> The peak of civilization.

30:49 >> Yeah.

30:49 >> The red button. Okay, don't press it.

30:53 What's next? I'm next with this one. Okay.

30:56 I want to start with some code and then tell you more about it.

30:59 I want to tell you the code and then you can think about how complicated is it and then what is this accomplished.

31:04 So here's some Python code.

31:05 It creates a little LED. It's for like some embedded thing.

31:08 It imports the LED, imports time, imports random.

31:11 It says LED equals LED number 17 while true.

31:16 LED on, sleep one second. LED off, sleep for between 45 and 60 minutes.

31:21 That's the entire bit of code.

31:23 What does it do?

31:24 This is how I automated my standing desk with a raspberry pie.

31:28 [laughs]

31:30 Pretty awesome, right?

31:31 Yes.

31:32 So this one comes to us from Joe Ridley.

31:37 Ridley.

31:37 Thank you, Joe.

31:38 And this is by David Kong.

31:40 It's apparently he's into sort of hacking his productivity in all sorts of ways.

31:44 So he got a standup desk and he said, I have this cool automated standup desk.

31:48 You can push a button for up, push a button for down.

31:50 He had presets of like where you like the up, where you like the down, but he didn't press it very often.

31:55 So he's like, "Why am I not pressing it?

31:57 Because I am lazy and I want to stand up." So he put reminders on his phone, says, "You want to stand up?" He goes, "No, I don't want to stand up right now." Then he said, "Well, what if it just did it?" I had to adjust to it.

32:08 He went along and there's a couple of buttons, little programmable bits, and he just pried the faceplate off of the control surface of his automatic desk, you know, it was a works desk.

32:21 So whatever, if it breaks, I guess, pry that off.

32:24 And it just has a few little like pins in the back.

32:27 And if you push the button down, it completes the circuit.

32:29 And he's like, well, really all I needed to do is stand up.

32:32 I can push the sit down button when I'm tired of standing up again.

32:35 And so went through about like, how do I do this?

32:37 I just need to connect something that will trigger electrical current on one of these bits here.

32:43 So I said, well, maybe I could use some little like super micro thing, some small things.

32:49 "You know what, actually for five bucks, "I can get a Raspberry Pi Zero, "and you'll go crazy, get a case and an SD card "and all that from Adafruit for five bucks, "and just write some Python code, "and then you connect these little pin areas, "number 17, for example, to a circuit, "and instead of turning on the LED, "it just sends a current over to that little thing "on the desk, and it'll make it go.

33:12 "Isn't that awesome?" - That's great.

33:15 I wanna do that.

33:16 I need a standing desk first, though.

33:18 I know. Here I am saying, Will, who is in the audience, has magic method names.

33:25 How do I know?

33:26 How can I tab complete?

33:28 And this thing's like, hook it up to terminal 17.

33:31 I mean, oh, OK, not 18.

33:32 All right, great.

33:33 Exactly.

33:34 It's pretty janky.

33:35 No, but that's great.

33:37 That is.

33:37 I've got to.

33:38 You have a standing desk?

33:39 Stand up desk.

33:40 It had a different brand, but it looks like the exact same panel.

33:44 And well, stay tuned.

33:47 So one of the things is like, I don't really need a UI, but maybe just a terminal.

33:50 And how do I talk to the Raspberry Pi?

33:52 So, David goes on to talk about, well, how he set up, an SSH shell over to his Raspberry Pi from his Mac book using a USB cable because he's it's on the desk anyway.

34:03 And then just writes this little bit of code that I talked about.

34:06 Move desktop pie and off it goes.

34:09 So I soldered a few things together and then just taped it to the bottom of the desk and now you have it going.

34:16 I would contend there's a few minor upgrades that should be added here.

34:19 Maybe a time check.

34:21 Like you may freak a custodial person out.

34:25 If they come in the middle of the night and they go to get the...

34:29 If they go to get like...

34:30 >> The clone army has been activated.

34:32 >> Exactly.

34:32 We're going to empty like the trash bin under your desk and you go, "No, Jacob." You would, I would run for it.

34:38 But if that were me.

34:40 But, you know, so maybe like a web service call to check the time or just check the time and go, do you really just do this during work hours?

34:47 And like, honestly, this was a pre COVID thing.

34:49 But so it randomly raises and lowers it or yes.

34:53 Between forty five and sixty minutes on the hour.

34:56 OK, that is fabulous.

34:58 Yeah. If you look at the comments here, this is where you got to hang tight, Paul.

35:02 So people are digging it.

35:05 Someone down here a little bit further says I have something called a very desk.

35:10 But it turns out when I peeled the front off of my very desk, It had exactly the same control board on the inside.

35:16 So yeah.

35:18 So Paul, you, if it looks the same, it may well be the same.

35:20 Cause someone else was saying that they did.

35:22 Now my desk is going to be smarter than me.

35:24 I mean, I've gotten used to my watch being smarter than me, but it will just have more willpower than you.

35:30 Cause you're like, I don't really want to stand out.

35:32 I can't reach it anymore.

35:33 So I got to stand up.

35:34 Boxing the hedgehog.

35:35 Yeah, exactly.

35:37 All right.

35:37 Well, that's all.

35:38 But I thought it was a, I'm always thinking of like, we have these super cool devices that cost like five bucks and it's, they're so easy to program, but I just, I don't usually have anything cool to do with them.

35:46 And this seems entirely attainable.

35:48 Yeah.

35:48 Yeah.

35:49 I think maybe, hooking up a height adjustment with, audit with random adjustment to my webcam would be cool.

35:56 So I could just have different angles throughout the day.

35:59 What if there's like a pulley system that if you, that after a moment yanks the chair and if you don't get up, it's just going to dump you like a little bit more urgency to the medic work.

36:08 Exactly.

36:10 or score a gun if he finds you're still sitting or something.

36:13 >> Puts my coffee slightly farther away.

36:15 >> Exactly. Paul, what's your last one?

36:18 >> This was a really interesting one for me.

36:22 I was on vacation in heaven in August, and two things I did was when I was at the beach, I had the beta of Brian's book, and when I was back at my mother-in-law's house, I was taking my six related Python projects and teleporting them into the future using the hyper-modern Python cookie cutter.

36:47 And what do I mean by that?

36:48 Well, if you're doing a Python package, a library or something that you're going to distribute on PyPI, you know, Python development's gotten...

36:57 The bar has been raised, let's put it that way, on quality control and tooling and things like that.

37:04 And my good friend Brian Okken long ago, 10 minutes, mentioned about XDoctest, which is also on here, I believe.

37:15 Yeah, XDoctest, along with 57 other things you might want to do, like Dependabot and Flake 8 and Precommit and mypy and Black and GitHub Actions and all these other things.

37:28 And individually, they're achievable.

37:31 Collectively, they are a go on vacation in heaven, delete your repository and start over.

37:38 That's what I did.

37:39 I deleted all my repositories and started over with poetry and things like that.

37:44 This cookie cutter isn't just great because it's a cookie cutter that gets you in the ballpark out of the box.

37:52 It is a user guide that explains all the decisions made, including the why.

37:59 It's like teaching you how to become a modern Python packager programmer, someone who's going to distribute stuff.

38:07 And in fact, there was a blog, a series of blog articles before he did this.

38:13 Let's see if I can find that.

38:15 Yeah, so often you'll see these articles of what you should do, and then you just have to go do it.

38:19 And this is like, here's what you should do, and then you run this command, and then it's done.

38:24 But now you know why.

38:25 Indeed. And in fact, I found the part you just described to be more valuable than the cookie cutter.

38:30 Yeah.

38:31 Because the last thing I wanted was to be teleported into 57 things I didn't understand.

38:38 Yeah.

38:39 And so just for the two of you, if you could look through that list, maybe anybody in the audience look through that list.

38:47 How many of these are things, Brian, you've been distributing packages recently.

38:52 How many are these?

38:54 How many of these things are in your list of guilt that you're not doing?

38:59 Yeah.

38:59 No, a lot of these are great.

39:02 Some of these I'd like to add, like, I'm not doing much type checking.

39:06 I'd like to do more type checking.

39:07 Sure.

39:08 I don't, some of the choices, I just don't agree with the choices.

39:12 So I was actually considering doing a fork of this with the choices that I would have made.

39:16 Like, Knox is a cool project, but I've got no problem with Knox.

39:20 Yes, I knew you would say that and I agree with you.

39:23 I would I would change that.

39:24 And I know you said you like poetry.

39:26 I know a lot of people love poetry.

39:28 It just doesn't fit my brain.

39:30 So I don't use poetry, but that's I'm only 50 50 on it.

39:33 I'm fighting it.

39:34 But a whole bunch of other stuff, like you said, things that maybe you didn't consider like black and prettier.

39:41 I don't think I use both.

39:42 So I don't know what prettier gives me the black doesn't.

39:45 JavaScript and markdown the things like that.

39:48 JSON files, non Python.

39:50 Oh, okay.

39:50 Don't know what release drafter is.

39:52 That looks neat.

39:53 The whole release drafter thing, I don't know if either of you have ever looked at release note automation in Python, but there's a number of packages, semi-dead, and most of them result in this dance of if you push before this thing runs, you can't get your notes on the tag.

40:12 Yeah.

40:13 And so this is hooked up with a GitHub action, which makes a draft of your release notes for you as part of the merging a pull request to bump the version number process.

40:25 It's just fascinating.

40:27 I would have never figured this out, man. Never.

40:29 Okay, we got some cool comments.

40:32 One here, it's not as from Exxon.

40:36 >> Yeah, that's a good point.

40:38 >> It's not as hyper modern as the title suggests.

40:40 It's often pretty solid advice.

40:42 I'm not sure if what he means by solid is a compliment or an insult.

40:47 >> I think what he means is hyper modern.

40:49 At least when I read, I was like, the last thing on earth I want is bleeding edge on this stuff.

40:56 >> Then also, List of Guilt would be a good title for this.

41:01 >> Yes.

41:02 >> One of the things I want to point out the article series.

41:06 At the top of this, what we're going to link to, it links to HyperModern Python.

41:11 It's a list of articles.

41:12 The artwork in this is amazing.

41:15 He's using some freely available artwork.

41:18 >> Japanese, really clunky thing.

41:20 >> Yeah, well said. Did you read any of the articles, Brian?

41:23 >> Well, I read all of them when they first appeared, but it looks like there's some newer articles that I haven't read yet.

41:30 Yep, yep. So Claudio, mega kudos.

41:35 That's another project I should join because there's a couple I would like to teleport him from Sphinx restructured text to Sphinx Markdown.

41:44 Oh yeah, definitely.

41:45 Which is what I've done in my, my, each time I did this, I did a commit immediately to replace it.

41:52 And it's a little bit of work.

41:53 And so it's a contribution I could actually make.

41:56 Yeah, Sphinx Markdown is the reason why I use Sphinx now.

42:00 Very good. Very good.

42:01 So one last thing I'll close with on the XDoc test, Brian, I was using it from HyperModern Cookie Cutter, and I switched to this from Chris Withers, Sybil.

42:13 Sybil, nice name.

42:14 Which is, Chris is an old time Zopista.

42:18 And so what he does is he lets you, this is not about doc strings in your code.

42:23 This is about blocks in your Sphinx, blocks of code in your Sphinx and testing them.

42:29 But you wind up with this doing something pytest-y.

42:35 And this lets you have fixtures and all these other things available in your doc test blocks.

42:41 Cool, we'll check it out.

42:43 Yeah, super, super cool.

42:45 And Eschleon said, "Solid was intended as a compliment there." Yeah, very nice.

42:51 Alright, Brian, you got any extras to wrap it up?

42:53 I don't, other than just an apology.

42:55 Sorry about the solid comment.

42:58 I don't know. That was good.

43:00 Anything else?

43:02 Yeah, I had a chance I guess at the end of last week If you've been to PyCon before you'll know some of the folks in the PSF Bessie Walshewski, who has been with the PSF forever and ever was with O'Reilly before that She is now with OSI, the Open Society God, I knew I would say that.

43:29 Open Source Institute, I spent 10 years on a project with the Open Society Institute, the other OSI.

43:35 And she is working with OSI on their messaging and fundraising and things like that.

43:43 And it's a very interesting problem for us in the Python community that's similar to the problem we had with the PSF, getting people to pay for the comments, if that makes sense.

43:58 Now, the comments for the world of open source is a lot squishier and the value proposition is a lot more indirect relative to the world of Python.

44:09 But I feel like there is a big there there that the world of open source is still relevant and still has important next problems.

44:21 There is a commons, there are things that will need to be done and we need a neutral agency that is an advocate for the commons to work on things like that.

44:34 So she and I discussed what's next for the commons, things going on at OSI.

44:40 If any of you were around in the beginning of the words open source, You know the problems that were being solved then, they feel like solved problems now.

44:51 But that's an open question and sometimes problems don't have a way of staying solved.

44:55 So keep an eye on OSI, keep an eye on what Betsy and Stefano and others are doing, keep an eye on open source itself, and maybe share some thoughts in the show notes or anything like that.

45:10 What do you think is the big mission for open source?

45:14 >> Yeah. Maybe you reply to the Twitter thread announcing this episode which will be out shortly.

45:18 That probably be the best place or the YouTube live stream chat would be good places for that.

45:24 >> How about you, Michael? Do you have any extra bits?

45:27 >> You know I do. First of all, I want to just really quickly on the hyper-modern thing throughout.

45:33 Remember we talked about readme.so?

45:36 >> Yeah.

45:36 >> Gosh, and this is readme as a service.

45:39 This is good to generate your readme and then you can use the release note thing to keep it going.

45:43 So yeah, I just want to give another shout out to that because idea of readme as a service blew my mind.

45:48 - Does it do badges?

45:49 God, badges are so hard.

45:50 - I know, if it doesn't do badges, it better.

45:52 That'd be an awesome upgrade.

45:54 Okay, couple of quick things I want to throw a shout out to.

45:57 These are at the bottom of the show notes.

45:58 ActiveState, you know, they're one of the packagers, distributors of more full featured, holistic, sort of pre-packaged Python distributions.

46:09 They are running a survey called the software supply chain security survey to supply chain security of like pip vulnerabilities, or not pip, IPI package, pollution vulnerabilities and stuff like that are our big deals.

46:24 So they're interested in running a survey.

46:25 So I thought I'd give a shout out about that.

46:27 People can fill that out.

46:29 Python 3.9.7 and 3.8.12 are out with I think 3.9.7 might have some very minor new things and 3.8 is just a security update.

46:39 So bug fixes, but the three nine one didn't speak to me as anything super major, but you might check it out.

46:45 There's a few security things in there about like, if you pass this to like the IP class or something like that, it could be an issue, but I don't really think there's anything super important there, but no.

46:58 Brian, this one, let me read the little description for you.

47:00 This one here comes from Shlomi Lantan.

47:05 Says, "Brian, you talked about having a history of all the files in a GitHub repo and finding out how long the oldest one, like we were just looking around, like how old is this project?

47:14 Maybe two years, looks like lasting change.

47:16 So he wrote a thing called Grandpa.

47:19 And the idea is simply find the oldest modified files in the repo, so you can run it standalone, you can make it a GitHub action and so on.

47:28 So it just goes through and finds the oldest files.

47:30 Last week I talked about WakePy, which will let you keep a process awake, keep your computer awake while your process, your Python processes running.

47:38 Do you do like a context manager, you know, with keep awake, do the stuff you don't want the computer to go asleep during. And then when you leave the computer can go back to sleep.

47:47 And I said that there was a problem on macOS, but PR has accepted that things back to good. So thank you for that.

47:52 Really quick shout out to some, oh my Z shell, not my Z shell, oh my posh shell.

47:57 Look at all that good stuff, Brian. That's, that could be your, that could be your, PowerShell on Windows.

48:04 >> Does it have VI key bindings?

48:06 If not, I can't use it.

48:07 >> I honestly don't know.

48:09 Anyway, I think it's pretty cool, but it's not just for PowerShell.

48:15 It just happens to be one of these really nice extensions that also works for PowerShell.

48:19 >> Oh, really?

48:19 >> Yeah.

48:20 >> All right.

48:21 >> It took me forever to know what Posh meant.

48:22 I'm like, "Posh, what shell is that?" Posh is PowerShell, right?

48:27 >> It probably is, actually. Yeah, it probably is.

48:30 It sounds cooler than PowerShell though.

48:32 >> Okay.

48:33 - Cool, cool.

48:34 All right, I think that's it for those.

48:36 Are you all ready for a joke?

48:37 - Yes.

48:38 - All right, here we go.

48:39 So here's a tweet from monkeyuser, @ismonkeyuser, and they have a mess, they have like this sort of planning diagram here, like a flowchart, if you will.

48:48 Remember a flowchart?

48:49 But this is like real high level.

48:51 And it's about trying to find a meaning as a software developer.

48:55 So if the person enters to the workflow, quit, question mark, yes or no?

49:01 Yes, do you have paid time off?

49:02 (laughing)

49:05 Then what you can do is you can go in and you change your JavaScript, I think it's JavaScript, change your JavaScript framework.

49:12 Did you acquire new skills?

49:13 Are you burnt out?

49:14 No?

49:15 You go back, you change your JavaScript framework again.

49:18 It's a little starving.

49:19 Have you changed your JavaScript framework in the last two months?

49:22 If no, then you need to change it again.

49:25 - It burns, it burns.

49:27 - Yeah, you've got some backlog here.

49:29 It goes to in progress and that gets shipped.

49:31 It gets done, you get paid.

49:32 Do you have burnout?

49:32 Yes.

49:33 Are you dead?

49:34 Whoops, not yet.

49:35 Do you have paid time off?

49:36 Then you can change your JavaScript framework again.

49:38 No, then you ask, has it been changed in two months?

49:41 If no, then you change it again.

49:44 Otherwise you go to the backlog.

49:45 And I thought this part right here, Ryan, you might particularly like, is it ready for QA?

49:49 Nothing goes to that.

49:50 (laughing)

49:53 It's just like an orphaned input box right there.

49:58 - This should be the logo for HTMX.

50:01 - Yes, it actually should.

50:02 Yeah, this would be awesome, 'cause it really, it just tells you the churn.

50:06 And another person walks up and says, "Hey, are you trying to find a new workflow "for how we're working?" He says, "No, I'm trying to figure out "why I'm still doing this." - Well, there's no way to go back to quit.

50:17 (laughing)

50:20 And there's, yeah, and--

50:23 - You found the Easter egg.

50:24 - Yeah, well, also, why is there still a separate QA department?

50:29 - I love the leveraging of paid time off.

50:32 - Yeah, backlog, backlog's like an afterthought.

50:38 If there's nothing else you can do, maybe you can work on the backlog.

50:42 - Yeah, exactly.

50:43 - Nice. - Awesome.

50:46 - Well, that's it.

50:47 Yeah, that's it for our show.

50:48 Brian, thank you as always.

50:49 Great to have you here.

50:50 And Paul, thanks for joining us.

50:51 - Thanks for having me.

50:52 Love the show.

50:53 Love everything the two of you have been doing for the last few years.

50:56 and hope to tell you this in person soon, but probably not.

51:01 >> Yeah.

51:02 >> That's wrong.

51:03 >> No, okay.

51:04 >> You said for me to interrupt you and tell you when you were wrong, but I forgot to, so.

51:08 >> Okay, great.

51:09 [laughing]

51:10 Keep happy thoughts.

51:11 Do you promise not to cut your hair until we see each other again?

51:14 >> Yes.

51:15 >> No, I'm wanting to be cousin it by next year at this time.

51:19 [laughing]

51:22 So, all right.

51:23 >> Love it.

51:24 All right.

51:24 >> Bye.

51:25 >> Bye, guys.

51:26 Bytes. Follow the show on Twitter via @PythonBytes. That's Python Bytes as in B-Y-T-E-S.

51:33 Get the full show notes over at PythonBytes.fm. If you have a news item we should cover, just visit PythonBytes.fm and click submit in the nav bar. We're always on the lookout for sharing something cool. If you want to join us for the live recording, just visit the website and click live stream to get notified of when our next episode goes live. That's usually happening at noon Pacific on Wednesdays over at YouTube.

51:55 On behalf of myself and Brian Aukin, this is Michael Kennedy.

51:58 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page