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


Transcript #285: Where we talk about UIs and Python

Return to episode page view on github
Recorded on Tuesday, May 24, 2022.

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

00:05 This is Episode 285 recorded May 24th, and I'm Brian Okken.

00:10 >> I'm Michael Kennedy.

00:11 >> I'm Mark Little.

00:13 >> I'm Ben Cosby.

00:14 >> Nice. Welcome, Ben. Welcome, Mark.

00:16 Michael, you have this story of why you brought Mark and Ben on.

00:20 >> Yeah, I did bring Mark and Ben on.

00:22 Mark and I have been really good friends for a long time, but that's not why he's here.

00:25 He's here because he's been sharing this Python journey that he and Van have both been on.

00:31 They come from law, like being lawyers and bankers and stuff, and they've found their way over to writing software in Python.

00:38 It's been so fun to watch you guys come along.

00:40 And you recently showed me the release of one of your SaaS products built with Python and Pyramid and other things.

00:46 And I thought it was just super cool, so I thought you could maybe share just a little bit of that before we kick off the main topics to kind of inspire people who are not, you know, traditional CS folks.

00:56 and they can still build amazing things.

00:57 You want to tell us a bit about yourself and then tell us a bit about your thing?

01:01 I'll say first that I'm strictly the hobbyist.

01:04 So we it's definitely been a collaboration and quite a journey.

01:10 And then I'll talk a little bit about how we got started, because you played an instrumental role in that, Michael.

01:14 But so we released this product called LexChart that builds corporate organizational structures automatically.

01:20 And these charts are kind of weird.

01:22 They're sort of like human resources, organizational charts, except that for legal entities, they're much more complicated.

01:30 And so we've built some automation in Python, principally, in the server side that generates these hierarchies automatically.

01:39 And they can be quite elaborate.

01:40 So for example, some of them we release publicly.

01:44 And we've been building these things with our own app and releasing them.

01:47 So here's one for Elon Musk, for example.

01:50 This is before the early stages of his Twitter acquisition, but our app does a lot of this layering automatically.

01:58 And those things can be quite stunningly complicated.

02:03 So here's one, for example, with thousands of legal entities in the corporate structure of Blackstone.

02:09 And so we've actually got some Python that sort of automates the presentation and structure of all that.

02:15 And then, as you say, it's using Pyramid and Chameleon and SQLAlchemy, and then a lot of legal and business finance expertise as well.

02:26 But it's been quite an exciting journey.

02:28 And so we were excited to share this with you and look forward to sort of talking about some of the piece parts that are in the product that might be useful to the broader community as well.

02:38 - Yeah, exactly.

02:39 Some of the stuff you guys are gonna cover today as our main topic sort of were extracted out of the building of the SRA.

02:44 - Yeah.

02:45 - Ben, anything you wanna add to that and maybe just tell people about yourself real quick?

02:48 As you pointed out, and Mark too, you know, whenever I'm trying to explain to somebody what I do now, I always say, well, I'm a reformed barbarian at the gate, I traded buyouts and IPOs and a suit on Wall Street or, you know, code and in my office at home and in my pajamas, kind of thing.

03:05 And, but we've, as Mark talked about, we've kind of merged those couple of things together.

03:10 And so these days I spend a lot of my time with Python on the front end and JavaScript, sorry, JavaScript on the front end and Python on the back end and DevOps and all sorts of things, you sort of have to do it all.

03:20 But I also wanted to say, kind of as part of our journey for your listeners, I'd be remiss if I didn't, even though I didn't warn you beforehand, I was going to do this, but along this way of kind of going from suits and deals and IPOs and things like that, Michael's Talk Python training, I'm sure lots of people on this podcast are familiar, but if you're not, those courses were pretty instrumental for us and for those we've worked with in evolving and making Python.

03:48 Python now is completely central to our business and what we do.

03:52 So it's been fun to get here.

03:54 Thanks for the shout out, Ben. I appreciate it.

03:57 I would just say, too, we've been able to leverage that.

03:59 And we've got some pretty complex math and graph theory in the core of our app.

04:05 So we've been able to take Michael's classes and really leverage them in a much bigger way that I think a lot of people expect or imagine they can when they start some of these online classes.

04:19 So, you know, your training in particular has been exceptional.

04:22 - Thanks, Mark.

04:23 I just think what you guys have built is looks so much more polished than somebody, couple of guys who taught themself programming a few years ago, and I just, I love it.

04:30 So, super good work.

04:31 Brian, should we kick it off?

04:33 - Yeah, this is just great.

04:34 I'm blown away.

04:36 It looks awesome.

04:37 So yeah, let's kick it off.

04:39 - Yeah, I was too.

04:40 And I think some of the stuff that we're gonna talk about is going to certainly be part of that.

04:45 So let's talk, yeah.

04:46 - Oh, whoop, nope, wrong one.

04:49 - I'm up next, right Brian?

04:50 - Yeah, sorry.

04:51 - All right, I have a whole bunch of extras, folks.

04:54 So let me just, I'm gonna start with like a quick one for one of our main topics here that maybe--

04:59 - We may have to cut you off.

05:01 - You might have to cut me off.

05:03 So check this out, Brian.

05:04 If I go to pypi.org and I go look for something like, let me look at Beanie, I don't know if I get that right.

05:10 Actually, I don't think that's gonna help, right.

05:12 Let me look for Switch Lang, which is my Switch implementation I added to Python, I don't know, a couple years ago.

05:18 So if you look over here on the left, oh, I think it's being blocked, but over here, it says, here's your avatar from Gravatar for M. Kennedy.

05:28 But my little, I don't know, my browser settings are blocking that or whatever.

05:31 But so this is a thing you see a lot of the times, and like, where do you get these little Gravatar, right?

05:38 So if you have users, you have users who have emails, you want to show something about there's a chance that over in Gravatar, there's going to be some profile for them, different images, things like that.

05:51 If you're in Python and you want to add Gravatar features to your site, it is ridiculous using this thing called libGravatar.

06:00 >> Oh, wow.

06:00 >> All you got to do with libGravatar is you go and you create an instance of one of these objects, Gravatars.

06:06 You pass in an e-mail and you can say, get image, you give it a size, and potentially a file extension if you want to control that or anything, whether or not you want to use SSL.

06:16 And then it gives you back this non-reversible URL that is the image of that person based on the size you asked for, who they are, and so on.

06:26 And if they don't exist, you get the standard Gravatar logo, just like a little circle type thing.

06:30 And so this is some kind of hash algorithm that you have to follow based on their email address to pull them back and so on.

06:36 But if you want to add that kind of Gravatar look and feel, then literally, Gravatar object, give it the email address, dot get image.

06:44 That's pretty neat. It goes from one to 248 pixels on the image size.

06:49 I'm not sure one's super useful, like you get one dot, but maybe you want it to be a particular, like a shade of the person is all you're going to get, I guess.

06:58 >> I feel like a five by five would be fun, just a few pixels.

07:03 >> It would. You can do a get profile, which will then give you access to the user and see all of their email addresses, all of their information about them and so on.

07:10 So there's a little bit more that you can actually--

07:11 - Gravatar is for social security.

07:13 - Oh yeah, yeah, there's this whole shadow profile that's built up by the surveillance ad tech industry.

07:18 It's only five bucks a use, no, just kidding.

07:20 But you can get more details about them through their profile if you really want.

07:23 But basically the main use case is, given an email, can I get a picture without hassling this person to upload a picture?

07:29 Maybe.

07:30 - And just, if anybody's not familiar with Gravatar, it's owned by Automatic, who does WordPress.

07:35 So all the WordPress people use it.

07:37 And that's why it's like well supported and it's not too evil or anything like that.

07:42 - Yeah, and like I said, PyPI.org uses it.

07:44 So that's a start.

07:45 Mark, Ben, what do you guys think?

07:46 Do you have user pictures in your app?

07:49 Are you worried about this kind of stuff?

07:50 - We don't.

07:51 - We don't at Let's Chart, but it's funny because at the very beginning of our journey, we implemented a little question and answer app as like a demo to make sure that we could like justify going down to Python and I use Gravatar in there.

08:05 This actually is a pretty cool library because I remember in that app, I really was just focused on Python, but I had to fall back on some JavaScript in order to put the Gravatar icons in there.

08:15 But it is a great, Gravatar is really useful.

08:18 I'd encourage your listeners, if you're looking for something, 'cause the nice thing, as you said, is it'll just generate this automatic little drawing, even if they don't have an image, so you can kind of create a nice look and feel for your site, for your user profiles, where everybody gets some sort of a graphic, even if they haven't uploaded anything.

08:33 It's kind of a nice little tool.

08:35 - Yeah, absolutely.

08:36 Kim Van Wick out in the audience says, when pixel Gravitars might be useful for building images like displaying contributors and stuff.

08:43 Maybe not one, but you could do like 10 by 10 and you could build up to a montage of all the people or something that'd be cool.

08:49 And you also, Ben, you also have some cheering folks in the audience, which is lovely.

08:55 (all laughing)

08:57 So go Ben, great to have you here.

08:59 All right, Brian, over to you.

09:02 I'm very excited about it.

09:03 When I first saw this, I'm like, "Oh, you don't really need that." Pydantic does this on, oh wait, no, this is amazing.

09:08 Tell them, tell them.

09:09 - So this is so cool.

09:11 It's a little thing that was suggested by Chun Li.

09:15 It's JSON to Pydantic converter.

09:17 And Chun said, "This awesome JSON to Pydantic is so useful.

09:23 "It literally saves me days of work "with complex nested JSON schema." So the idea is you've got, basically it's just this website with a JSON side and a Pydantic side.

09:36 I've got one prepared.

09:37 I went and copied one from somewhere.

09:40 If we go over and just replace the simple one with a more complex one, paste it in there, and then it just generates the Pydantic model, and it's pretty awesome.

09:51 There's a couple of options.

09:53 >> For people who are listening, it's not that it converts JSON to Pydantic, it converts JSON to Pydantic code.

09:59 >> Yeah.

10:00 >> Writes the code that you would have to write for the Pydantic to understand what you put.

10:04 It's amazing. I love it.

10:06 >> Right. Then some of the options are cool.

10:08 You might not use it for everything, but just knowing the syntax for it.

10:12 If you give them optional, it'll tell you where to put optional in your model to make it all work right.

10:19 This one's only just showing up at the bottom.

10:23 Then the last one is aliasing camel case.

10:27 I didn't know you could do this.

10:28 aliasing camel case for snake case.

10:30 So if you're using, I guess both camel case and snake case, you can have them work. I don't know.

10:36 >> A lot of times if you're consuming a JSON API that's written in another language, the variable names are idiomatic to that language.

10:43 So like C# or JavaScript would represent this one where you've got the camel casing, but that would not be how you would want to call it in Python.

10:52 So you can say, well, give me the Python version, but allow Pythonic to find the other size.

10:56 >> Okay, cool. One of the neat things about this that I really love is it's an open-source project.

11:04 At the bottom, there's a link.

11:06 It takes you to just the open-source page.

11:10 This is built with FastAPI and Create React app, which is pretty cool, and then a data model code generator.

11:18 That's doing the most of the work.

11:20 If you want to do this yourself somewhere else, embed it within your tool chain or something like that, you can do this.

11:28 I don't know why you'd regenerate it all the time though, but it's just super fun to just drop some adjacent example of good one in there and drop it in.

11:39 >> It's fantastic. If you're going to consume an API and you say, here's a specification of what I'm going to get back, boom, you're halfway there or you're a consultant, you pick up somebody else's code and you're like, I want to use PyNanic here, this is great.

11:51 Anthony, the artist, says, "Oh, "Oh, come on, I could have used this last week." (laughing)

11:57 Guys, what do you think of this?

11:59 - That's really cool.

12:00 We have a project where we're looking at migrating from a different tech stack to Python.

12:05 And one of our output sources there is JSON.

12:07 So I'm looking at this and wondering, Ben, this might be an opportunity for us to get there a little quicker for some of that data.

12:16 - That is cool, especially for prototyping or something where you just wanna see and you wanna spend three days seeing what it's going to look like.

12:24 This is pretty cool.

12:26 - Yeah.

12:26 - Yeah.

12:27 - Yeah.

12:28 It's very cool.

12:29 - Also another, I mean, we get this all the time, but I just want to remind people, this was a suggestion from a listener.

12:35 And that's one of the neat things about the podcast is people can find cool things and send them in and then we can share it with everybody.

12:41 It's nice.

12:42 - Absolutely.

12:43 That's like half of our topics are that, right?

12:45 All right, Mark, you're up with the next one.

12:47 - Awesome.

12:48 So this is not a Python library and it's probably well known to most of your listeners, but I wanted to just talk about a few Tailwind CSS things that people, if you're only sort of casually aware of Tailwind, might help you jumpstart.

13:04 We are an aggressive user of Tailwind and some of the components.

13:10 The other piece I want to talk about is Tailwind UI, which is not open source.

13:14 So Tailwind CSS is completely free from Tailwind Labs, But Tailwind UI is behind a paywall, but these are pre-built components by the creators of Tailwind.

13:27 So there are lots of people building components for Tailwind, but Tailwind UI is specifically built by the people who created Tailwind in the first instance.

13:35 And it's interesting to me, I know that both of you have a lot of interest in user interface design around Python and web apps and Tailwind certainly is a part of that theme.

13:46 And it's also interesting for the business model piece about how to turn sort of open source into sort of a revenue generating model.

13:53 So you can use Tailwind and never need Tailwind UI, but if you need examples or references, Tailwind UI is a fantastic resource.

14:03 And so I thought I would just show, they've got widgets, basically prebuilt components around marketing or app UIs and then a new sort of e-commerce section.

14:12 And to give you an example, there's really low level granular stuff.

14:15 Like if you want a little stats component, you can come in here, they'll show you what it looks like.

14:20 They've designed several options.

14:23 You can see what they are like responsively, and then you can actually see the code and they'll give you the code in raw HTML, React or Vue.

14:32 And some of them need JavaScript as well.

14:35 They'll give you hints around what to do with the JavaScript if that's necessary.

14:39 But this is an example of that little stats widget with all of the sort of Tailwind classes built in there that you can grab and reuse.

14:49 And we have found it really useful for creating this sort of really professional sort of user interface experience.

14:56 And our app, so for example, if I just quickly create one, like our toolbar here is a couple of chameleon templates with Tailwind running around each of these buttons to keep them consistent, which also means that at different resolutions, the buttons will look different.

15:13 So if I'm on a larger screen, there will actually be help text underneath each of these buttons.

15:17 They get smaller.

15:18 All that's done really nicely in Tailwind.

15:20 And then we can, because it's a chameleon template running in our Python stack, we can use those toolbars in a variety of circumstances and have really granular, nice, intuitive control of them.

15:31 So, you know, between Tailwind CSS and Tailwind UI, these are sort of great resources to get familiar and up and running with it.

15:39 There have been a few people--

15:40 - This is so, Mark, this is so nice.

15:42 Just to give people a sense of like some of the size of the building blocks is we've all gone to the websites where you click pricing, for example, and it's got like the three columns and one's a little bigger and it says this is the most common or whatever.

15:53 Yeah, that is just a drop in element here. And it's so beautiful, right?

15:59 Yeah. And what's this is the best thing about Tailwind from my perspective is it's built principally by Adam Wathen and Steve Schroeger. And Adam, I'm probably grossly oversimplifying would be the technical component of this, and Steve is the design element.

16:16 And they have some great resources.

16:17 If you just, Steve's over has some wonderful videos where he sort of recomposes user interfaces and he's got a book out on refactoring UI that I think you can add to the show notes.

16:28 But you're basically standing on the shoulders of these giants, right?

16:32 These are fantastic design principles.

16:34 Yes, I'm sure there are people that are better than me at doing this, but I know that Steve and Adam have done a fantastic job in using these components.

16:41 even if I need to tweak them, I learn a lot.

16:44 There are a lot of comments that people will learn a lot about CSS just watching them work and seeing how these components are built.

16:51 Tailwind automatically handles lots of cool edge cases and you see that when you look at these components.

16:57 And they're, you know, everything is built to be responsive from the beginning and they're just lovely to work with.

17:02 - Yeah, yeah.

17:04 - It's also super fast, so they're a bunch of components.

17:06 Their latest release has made their just-in-time compiler native, so it's built in.

17:11 It does generate a lot of CSS, but it will only do that if you're actually using, you know, certain classes or components.

17:21 And so it's just been fantastic to work with.

17:23 I will also say, we used this in a recent project.

17:27 You can actually drop Tailwind into an existing project and avoid conflicts with existing CSS.

17:33 There's a way to have a custom prefix on all the Tailwind classes, And both PyCharm and VS Code, their Tailwind plugins will adapt to that prefixing.

17:43 So for example, instead of it, if you need padding, you just append or prepend TW hyphen to the classes, to the Tailwind classes, and VS Code and PyCharm will pick up that prefix.

17:58 They'll still give you all the helps and prompts for Tailwind, and you'll avoid all the conflicts with your existing CSS.

18:03 - Yeah, it's amazing.

18:05 - And then finally, I'd say it's just, It's great with template languages.

18:08 So whether it's Chameleon or Jinja or Mako, it's really nice because you're just looking at that little bit of HTML in those templates and you can just put the classes right there in the HTML and have a high confidence in what that's going to look like.

18:23 - Ryan, have you played with this any?

18:25 - No, but one of the things I was having a, did a little consult with somebody trying to get a startup off the ground.

18:34 And I was looking at their site and I was like, man, your site looks awesome.

18:38 Did you hire somebody?

18:39 And they said, no, I'd use Tailwind UI.

18:41 And actually, so that's the thing, the sweet spot I think, is somebody that like maybe took the Michael's entrepreneurial course or something, just like one or two people that are trying to get a business off the ground.

18:56 You don't have any money, you can't hire somebody.

18:58 Or maybe you do, but often you don't.

19:01 So having this-- - Or it might just be - Too early to worry about that, right?

19:05 - Yeah, so starting off the ground with a professional looking site, I think that's a great way to start.

19:11 So, and yes, it's not free, but it's also not out of the realm of a small startup.

19:17 - Yeah, I would add, we've used a lot of frameworks.

19:19 We've used Bootstrap, of course, Semantic.

19:22 We've used a lot of these things.

19:24 And what Tailwind is nice, particularly Tailwind UI, Tailwind in general, but Tailwind UI as well, is they will give you full page references.

19:31 So if I scroll down here, you'll see, for example, there's this page example.

19:35 So if you need a landing page, they will show you what an entire landing page looks like.

19:41 But you don't have to take the entire page.

19:44 If you want to assemble these components individually into your own page structure, you can certainly do that.

19:51 So here's a Feature section.

19:53 It doesn't include any of the other stuff.

19:55 But if you like this feature presentation, you can go grab just this bit and mix and match it.

20:00 So unlike a lot of the theme kind of frameworks where you have this entire three in theme that just sort of stomps all over your design, you can actually get a custom looking output with Tailwind that's still consistent.

20:13 So it's a nice balance between, you know, pretty modular granular control, but still a consistent look of the entire app or website.

20:20 - And I have no doubt that like the stuff behind it, like how much CSS is there, the size, it's probably gonna be a heavier site than having somebody custom write all this stuff, but it's also gonna be cheaper, so.

20:32 - Yeah, and that is true.

20:34 What they have done, they have a just-in-time compiler that really minimizes the amount of CSS they produce.

20:40 And then of course you can do, they recommend using PostCSS and a number of other things like CSS Nano to sort of reduce the size of those files.

20:48 We still get very high performance.

20:49 So keep in mind sort of our app is built entirely with Tailwind, plus we're doing a lot of math on the server side And we get very small sub-second returns on our pages as a result, even with all that stuff.

21:03 - Yeah, that's cool.

21:04 You've definitely inspired me, Mark, to think about rewriting a lot of what I've been doing in Tailwind, and it'll get there.

21:11 I'm just not there yet.

21:12 I've got other stuff to work on first.

21:14 All right, before we move on, Brian, can I take a moment to tell you all about our sponsor?

21:19 - Yes.

21:20 - Yeah, so this week, the show is brought to you by Compiler, the Compiler podcast from Red Hat.

21:26 Just like everyone on the show and everyone listening, Brian and I are fans of podcasts, and I'm super happy to share Compiler with you.

21:33 Comes to you from Red Hat, a well-respected open-source company we all know of, I'm sure.

21:39 So with more and more of us working from home, it's important to keep our human connection with technology, and Compiler unravels industry topics and trends, things you've always wanted to know about from tech all the way up to interviews with people who know it best.

21:54 So on Compiler, you'll hear a course of perspectives from diverse communities behind the code.

21:59 Conversations include questions like, what is technical debt, or what are tech managers actually looking for, and do you have to know how to code to get an open source?

22:08 I was actually a guest on Red Hat's previous podcast, Command Line Heroes, and Compiler is following along in that same tradition of being an excellent, produced, and polished show.

22:17 So actually the show that they just released, When Should Data Die?

22:21 I think is one of those cool sort of philosophical questions of should data have a lifetime?

22:28 Should your data be able to outlive you?

22:30 All those kinds of things are pretty interesting.

22:31 So I recommend people check it out.

22:33 Just visit pythonbytes.fm/compiler.

22:36 The link is in your podcast show notes.

22:38 I know we're all smart developers who are listening.

22:41 You can just search for compiler in your podcast player, but please sign up by clicking that link and then clicking your podcast player.

22:46 it'll help them know it came from us.

22:47 So thank you to Red Hat and Compiler for supporting the show.

22:51 All right, I guess I'm still up, huh, Brian?

22:53 So let's talk peps.

22:55 This PEP is pretty interesting.

22:57 This comes to us from Ijmar.

22:59 It's by Jermaine Bravo and Carl Meyer, sponsored by Barry Warsaw.

23:03 And it's something, honestly, I'm surprised it hasn't been covered or addressed yet.

23:09 I think this comes out of Meta's Cinder project, where they're trying to do a whole bunch of performance improvements, but I'm not 100% sure, so take that with a grain of salt.

23:20 Basically, the idea is, right now, what happens when I write some Python code outright at the top, import requests, import Beanie, import FastAPI.

23:30 What happens when I import Beanie?

23:31 Well, inside Beanie, it says import motor, import Pydantic.

23:36 What happens inside motor?

23:37 It says import, it's just this transitive closure of at the top of all of these projects, each one of them is importing something and like parsing and compiling the Python code as in, you know, into abstract syntax trees into memory and stuff like that.

23:52 All of that happens when I write one import line, right?

23:55 That's a lot.

23:56 But what if there's different paths in my code and only some of the time, maybe I'm using Pydantic or only later in the app am I actually using FastAPI but not right away.

24:07 And sometimes you might not use them at all, right?

24:09 I could do a bunch of data science imports but only if a certain function runs do I care.

24:15 So this pep, this pep-9-690 says, well, let's not do that.

24:21 Let's not preload every possible path that you might run when you're gonna use a library.

24:27 Let's wait until you use it.

24:28 So that import fastAPI kind of just hangs there until I say fastAPI.

24:34 And soon as that first line of code runs there, then the import happens.

24:37 So you don't have this transitive closure all these imports if you're not actually going to use them.

24:43 So it helps with startup time and it also maybe helps with overall performance if not every bit of code runs.

24:50 >> I want this.

24:52 >> It looks cool, right?

24:55 >> One of the things-

24:56 >> You can save a lot of time in startup just because of all the import statements.

24:59 >> Yeah. One of the things that I face a lot with helping people is with pytest.

25:05 So pytest imports your code.

25:07 So it does it when it when it's well, it imports your tests, and then the tests and will import your code to run your code. But if you're running, if you're going to like, for instance, Ray, stop on the first failure, you're not going to hit a whole bunch of that code. And so avoiding, avoiding those and getting to start earlier, it would help help that. And, you know, that's just one example of startup time being helped. Now, I'm curious about how it helped, if it'll affect runtime early on, otherwise, you know, at post startup.

25:41 There's some conversations about compatibility.

25:45 So what could happen is there could be side effects that happen because of the import, right?

25:51 You're not supposed to make changes to the system, but that's arbitrary code writing during your import statement, right?

25:56 So it could have an effect.

25:59 So theoretically, this could change things.

26:01 And they refer to the not the lazy ones as eager imports.

26:05 But they do talk about how some of these, you'll have to pass a runtime flag to the Python interpreter or set an environment variable for this to happen by default.

26:14 It won't happen by default.

26:16 It's off by default.

26:18 So for better or worse, maybe someday that'll change.

26:20 But right now, That's pretty cool.

26:22 I like it.

26:23 Yeah.

26:24 Yep, indeed.

26:25 Ben, Mark, you guys have thoughts on this?

26:27 Yeah, I agree.

26:28 I think this is really interesting from the front-end world, where I spend a lot of time, too.

26:33 There's a billion analogs for this. We do all kinds of jumping through hoops from the old days, code splitting in the old days, and all kinds of webpack and a million other roll-up and all sorts of ways of trying to take advantage of this on the client side because of the browser.

26:48 But I can actually imagine a lot of situations using Python where what in one app, maybe it is just limited to that moment of startup.

26:58 But I can imagine a lot of situations where the way that your app or your service is being used is causing that initial run event to be an experience that the user is having on a more frequent basis, based on what you're doing or what you've constructed.

27:15 So that's actually really cool.

27:17 And I haven't thought much about this, but I kind of agree with you.

27:20 Sort of surprised now that I see it.

27:21 >> I should have always done this, right?

27:24 - I've heard that conversation before.

27:26 - Yeah, absolutely.

27:27 And I also wonder if it allows you to have code that can be less, have more optional dependencies installed.

27:35 So like, for example, I think it was a FastAPI.

27:39 There's some support for form stuff you have to install as a separate pip dependency.

27:44 And here you could just write that code and unless you actually run it, it doesn't matter if you have import that thing that's missing because not until does it try to use it, Is it gonna be a problem?

27:54 So it might allow you to write simpler code.

27:56 Let's see, out in the audience, Eddie Bergman says, I feel like with it opt-in, many people won't know to use it, but making it opt-out could break so many systems depending on the behavior.

28:05 So yeah, it's, I don't know what the right choice is, so I guess the safe one is to just opt-out, or to make people opt-in.

28:11 - Yeah.

28:12 - And Beanie, the author of, sorry, Roman Wright, the author of Beanie, gives it definitely a thumbs up for this idea as well.

28:19 So support for some framework, author's there as well.

28:22 All right, Brian, what do you got for your last one here?

28:25 Hope it's something rich for us.

28:26 - Well, I've got a couple of things that, a couple of these are small, so it's sort of a multi-grab bag.

28:32 pytest Rich, so this is a plugin for pytest that uses Rich.

28:37 Not much more to say other than it's kind of cool to use Rich to have some nice output.

28:42 This was done by Bruno Oliveira, who is one of the core people on pytest, And also the only other person on the planet that I know of that has written a book focused on pytest.

28:55 But cool guy.

28:56 He said this is a proof of concept and he'd love for somebody else to take it over.

29:02 But it doesn't look like it's dead or anything.

29:05 It's got some activity.

29:06 So anyway, I think this is fun.

29:09 So cool opportunity for people to jump in if they want to.

29:13 - Nice.

29:14 Question from the audience, Ryan.

29:15 How's it compared to pytest Sugar?

29:17 - I haven't.

29:18 - I'll borrow.

29:19 - I've used Sugar for a really long time, but you can look at the image.

29:23 So it looks like a similar to Sugar, but Sugar doesn't have these cool rich trace backs in it.

29:29 So there's that.

29:32 So the next thing I wanted to talk about before we move on to somebody else is a short little thing.

29:37 This was a recommended by actually the Pytest Rich was recommended by Brian Skin.

29:43 Thanks, Brian.

29:44 And then this is recommended by Henrik Finnsberg is a video by Anthony Sotile on how to get images in readmes.

29:54 And I guess I didn't know how to do this.

29:55 We encourage, and I wanted to bring this up 'cause we encourage everybody to put pictures and animated GIFs and all that sort of stuff in your readme so that when we re-review stuff, we can see what it does.

30:07 It helps, but it's not hard.

30:09 So Anthony goes through this whole thing of like, you don't have to put the image in your repo.

30:15 you just have to drop it into a comment field or in a repo edit field, and then GitHub will just put it on a CDN somewhere.

30:25 So the image is just there.

30:27 So some magic there.

30:29 - Kind of trick GitHub into uploading it and then not actually.

30:32 - Well, I mean, since the README supports it, it's interesting.

30:36 Anthony talks about using a comment field of your issues to drop a picture in and then you get the URL from that.

30:48 But if you just go into your readme within GitHub on the web interface and edit there, you can also drop it there and it just works fine.

30:59 I guess maybe he's thinking that you're probably not gonna edit your readme directly, you'll probably edit it locally and push it in, you can still do that.

31:06 It's neat.

31:08 - Yeah, very nice.

31:10 Yeah, people should definitely have pictures and explanations and charts and all sorts of stuff in their readme, so this is great.

31:17 - I would just add more generally, docs and tutorials can be a strategic asset when done well.

31:24 Tailwind does this amazingly well, EdgeDB does it really well, DigitalOcean is off the chart in the comprehensiveness and thoroughness of there.

31:31 And those things become an asset for the business instead of an annoyance that you have to do, the docs actually become valuable for the project or the business.

31:39 - Do you want to be there Or do you regret that you have to go there, right?

31:43 - Right, exactly.

31:44 - All right, Ben, you wanna take us out of here with your final main topic?

31:48 - Yeah, so as you mentioned, part of our latest project, LexChart, that Mark's talked a little bit about, one of the things that we had to do, despite the fact that as we were getting close to it, I realized you can use LexChart for a lot of things that maybe we didn't think about when my 12-year-old daughter sent me, I spun her up an account so she could tinker with it, so I could get an interesting test case out of somebody that has no connection to what we're doing.

32:17 And she sent me a little organization chart of Encanto characters and their family tree from the movie Encanto.

32:25 So I wasn't expecting, but she's not really our typical user.

32:31 And with our target audience, who looks a lot like I did in my former life, security is a big, big deal.

32:39 with our clients. And so one of the things we obviously had to look at is, you know, we need to implement some multi-factor authentication. And, you know, initially my knee-jerk reaction to that was, "Okay, yeah, we'll just do what everybody does and, you know, we'll set it up and you'll get an SMS message on your phone," and all that kind of stuff. But as I looked at that more and thought about some of the conversations we'd had with clients of some of our other software, you know, I wondered how long is that really going to last?

33:12 Because there's a number of kind of real security issues with, with SMS, not least of which is, you know, just the way voice networks are built, everything sent in, in clear text, it's actually really not that hard to, yeah.

33:25 It works, but people do look down upon it a little bit.

33:28 They're like, this is not quite real security.

33:31 This is better than nothing, but right.

33:33 Yeah, exactly.

33:34 Right.

33:34 And it's not to say, you know, you make me a point, it's everywhere.

33:39 Everyone's using it.

33:40 And, you know, by the way, yeah, absolutely.

33:43 You know, password plus MFA, even with SMS, is great.

33:48 It's so much better than the password only from a security standpoint.

33:51 So it's not a knock on it.

33:52 You know, I just thought, well, maybe we need to step one more step forward here and see if there's some other things.

33:58 And so, you know, I was looking for a library that could help us with one-time password stuff and specifically one that can help us with time-based, one-time password implementations, which is something that I think Google really ultimately started, this way back.

34:13 And that's why a lot of people associate this with the Google authenticator app.

34:17 but there's actually a lot of authenticators.

34:19 It's an open standard.

34:20 and it really is closely connected to what's happening when you do it.

34:24 With SMS or with email, both of those are similar in that, you know, both of these approaches.

34:30 they just lean on a moving factor.

34:33 So in the case of your SMS, that moving factor is just usually like a counter in the database, just clicking forward and whatever, and that's along with all the other secret sauces, generating these temporary codes, if you will.

34:48 In Timebase, the moving factor is time.

34:51 What that allows you to do is have an authenticator app where you don't actually have to communicate with that at all, But based on a shared secret, again, same as how you do with SMS.

35:03 You're able to sync up these passwords and then they have, they explode if you will, so they last for 30 seconds and all that thing.

35:13 >> Yeah, the library you're highlighting here is PyOTP, which I guess lets you do this really easy in Python.

35:19 >> It does. Yeah, it makes it really, really straightforward.

35:23 I've in the notes, people will be able to see. I put a couple of representative functions that you could use to do this, but it's a very small amount of code. Basically, you generate a secret, you store it with your user credentials, then when you're actually verifying somebody, they come in, you have the shared secret in there, they pull up their little authenticator app on their phone.

35:54 I think most people know what this looks like, but we'll do this there.

35:59 So that's the Google Authenticator app.

36:02 And so it gives you a little code and you can see it ticking down and all that kind of stuff.

36:08 And so instead of getting your SMS, you just pull up your code, you hit your app, you type it in, and then your users are putting that.

36:14 And then you're just running that through the verifier.

36:17 And based on this share secret, it says, yeah, you're the real guy.

36:20 Great.

36:20 And every 30 seconds, those go away.

36:22 So even if somebody just looked at mine for my Google Authenticator, you've got 30 seconds to figure out my password.

36:28 Exactly.

36:29 If you can get into that test account that I'm showing you that for.

36:34 But yeah, it's super, super simple to implement.

36:37 The only thing for the Python crowd here is that it is helpful from a setup standpoint to do a little bit of front-end work, because the easiest way for users to set this up is to scan a QR code.

36:51 And so we have that implement on the front end where you can see that QR code and scan it from a setup.

37:00 But those little functions I put in the show notes, you just spin up a little URI.

37:05 You can put that into any kind of QR code generator, including Python-based generators, if you actually want to do that, store the image on the server and then serve it up.

37:13 In our case, I actually do that on the JavaScript side.

37:16 And I put a little link to QR code.

37:18 which is kind of one of the most widely used, you know, NPM packages for that purpose.

37:24 Display that to user, they scan it, they set it up, they pair that first time, and then, you know, takes a little getting used to for the user.

37:30 I think, you know, at the end of the day, SMS is a little more user-friendly, just 'cause people are a little bit more familiar with it.

37:36 This isn't a big leap.

37:37 So we went here instead of something like WebAuthn, which is, you know, even probably better from a security standpoint, but I think a bigger leap for users.

37:46 So we just think it's a cool little library.

37:48 It's easy, it's purpose-built.

37:50 Literally those few lines of code that Sean puts, it's almost everything that you would need to implement this on the backend.

37:55 There really isn't anything else.

37:57 - It's amazing.

37:58 I've always avoided doing this because I'm like, ah, it's probably kind of complicated.

38:01 I don't want to screw it up and unlock people out, but it looks really simple and fantastic and straightforward.

38:06 So yeah, this is a great suggestion for people.

38:09 - Yeah, cool.

38:10 - Brian, have you had to do any of this?

38:12 - No, but I do have like a Sass app in the works that I don't think I'll get that complicated.

38:19 'Cause I think for somebody like with GitHub, we have to use it, like something like that for GitHub now, or you can, and I have set it up.

38:27 But some people, for some kind of apps, it depends on your audience.

38:33 Some audiences aren't really gonna want that.

38:35 - Sure.

38:36 It also depends on what you're protecting.

38:38 - Yeah, exactly.

38:39 Most of our clients are B2B large corporations sort of all over the world, and many of them already have these authenticator apps.

38:45 And the nice thing about this solution is it works with any of them.

38:48 So you don't have to as a business, you don't have to direct your clients to use a particular authenticator app.

38:54 So if you're using Microsoft or Google or Twilio's Authy or any others, you know, you can just plug this in and just use it.

39:02 You know, we test and validate on those three, but it'll likely work on any of them.

39:07 And so it's really nice in that corporate environment to just to slide in.

39:11 Yeah, and I should have emphasized for this audience, one of the great things about this is SMS is not expensive, but this is free.

39:17 It's free for you from a developer standpoint, and it's free for your users.

39:21 These Authenticator apps are free downloads.

39:23 This isn't, you know, you're not imposing any friction on your users from that standpoint, just a tiny bit of a learning curve for them.

39:30 But I think what you find, like you said, GitHub, you can link an Authenticator app to GitHub if you want to add MFA to your GitHub login, which, you know, I would say most of your listeners probably are familiar with.

39:40 And so, you know, if you're wondering about it, I'd encourage you to just try that.

39:43 Download Google Authenticator, Microsoft Authenticator, implement their MFA.

39:46 You'll see what the experience is like.

39:48 And you'll probably find that not really probably a big hard sell with your clients.

39:52 If in fact MFA is something you need, as you say, you don't need it, you don't need it.

39:56 But if you do, you know you do.

39:57 And, you know, this is a solution I think people should consider because I think SMS, you know, is fine and great.

40:05 But obviously, the more widespread it becomes, the more likely people are to attack it.

40:11 And the hacks on this are not hard.

40:13 My favorite one is using a cell signal booster, which some of you have heard of, especially some of your listeners that don't live in urban areas and whatever.

40:21 And I'm not encouraging this, but if you poke around just a little bit, it's not going to be very hard for you to figure out how to hack a cell signal booster.

40:28 And people don't even know they're attached to it.

40:30 And you can listen to everything and record all their texts and all that.

40:33 So that's a nervous getting ideas.

40:37 I got to go guys.

40:40 I, I, I love having this.

40:43 I use Authy and I just checked my Authy has 45 different accounts doing two FA MFA, which is fantastic.

40:50 Yeah.

40:50 I like Authy as well.

40:51 Yeah.

40:52 Brian, what else we got?

40:54 well, I've got a few extras.

40:56 do you have any extras?

40:58 you know, I do.

40:59 All right.

41:00 Yeah.

41:00 I'll, I'll, I'll do my first.

41:02 So let's start with some real quick ones.

41:04 First of all, Mac Rumors points out that the machine learning framework PyTorch, traditionally these have been like mainstream GPU, these machine learning training frameworks, and especially focused on NVIDIA, which if you're on a Mac is a problem because you don't have NVIDIA, not even before the M1 stuff, you had Radeon chips and stuff.

41:28 So doing hardware-based machine acceleration was really tricky.

41:32 They are now supporting Metal on Apple, which means you get GPU accelerated training on the new Apple Silicon Macs, including the M1 Ultra and all that stuff.

41:41 So if people are on M1, they may check that out.

41:45 That sounds good.

41:46 Let's see.

41:47 I got a message from Harry.

41:49 This is a 15-year-old kid who said, "Hey, I built this learning platform "and a bunch of tutorials with my cousin, Anna, who's 14." And they built this app, which I'll link into, called Mission Encodable, and you come in that you can do little tutorials and you've got like little lessons and achievements to do after and stuff.

42:08 So anyway, I just thought I'd give him a shout out because it's really cool that a 15 and a 14 year old put this together for people.

42:14 Yeah.

42:14 Very cool.

42:15 Yeah.

42:15 All right.

42:16 two real quick things as well.

42:18 I use Calendly, Calendly, not misstating that.

42:21 That's how it's supposed to be.

42:22 Calendly.com, which is great for like sharing your available free time.

42:27 People can sign up and book slots with you.

42:29 I recently learned about cal.com, which is an open source.

42:33 Parallel or equivalent to calendly.com.

42:36 So if you can self host it, or you have a free version, you can even have them host it for more pro things if you want.

42:43 But I just thought it was kind of cool.

42:44 There's an open source cal.com, which is Calendly.

42:47 And on the same vein, if you've heard about Firebase, which is kind of like the backend platform for so many mobile apps and stuff, so you don't have to have a a website and an API and a database and users, like this would handle all of those things for Firebase.

43:03 There's, I also heard about Supabase, like super but without the R, Supabase, which is the open source equivalent of that, so you can have sort of like the back end cloud for free for your, an open source for your mobile things, if you care about that.

43:17 And yeah, so those are my, oh, I have one more actually I wanna share with you.

43:24 So we've all heard about PyScript, right?

43:28 PyScript is awesome.

43:29 This comes from Anaconda.

43:30 It takes the CPython runtime and turns it into WebAssembly and then runs it in your browser.

43:36 And I've been looking at the PyScript.net website and they've got all sorts of cool stuff in there.

43:41 And if you go to PyScript/examples, there's actually a bunch of examples.

43:47 You showed the one, you covered this last time.

43:49 I think it was last time or time before.

43:51 You covered the anti-gravity one and those kinds of things, right?

43:54 What's lacking from here is anything that looks like a regular application, right?

43:59 - Yeah.

43:59 - So I said, well--

44:01 - What's the to-do app?

44:02 - The to-do app is not a regular, you gotta, come on now.

44:05 (laughing)

44:07 No, no, it's, you're right though, that is the absolute closest by far.

44:10 But everything here says, data science, data science, I want Jupyter in the browser, but not with a server, run it in the browser.

44:18 And that's fine, but that comes, I think, far short of the potential.

44:23 Okay.

44:23 So I, this weekend, I'm like, I'm going to fix this.

44:28 And the way I'm fixing it is with this project in a video that I was working on right before we jumped on, I'll publish it later today called the PI script PWA weather app.

44:38 So check this out.

44:39 See this thing here on the screen.

44:41 This is an application that installs in your doc offline.

44:45 It installs in your doc.

44:46 It's written in Python and PI script and with Python on the front end and has no back in stuff locally, felt like electron or something like that.

44:54 It's a progressive web app.

44:55 It downloads all the files, including the 15 megabytes of the Pio died runtime and PI script.

45:01 Puts it offline.

45:02 And when you run it, it just starts instantly.

45:06 So from a cold launch until you have this thing up and running, it's about two seconds and it goes out and it talks to an API and gets this cool weather here.

45:15 And like, you can have a little button.

45:17 You press this refresh button.

45:18 It goes pop, pop, pop, refresh.

45:20 It's as you click it, it's instantaneous, the way it sort of interacts with it.

45:24 And all of it is written on the front end using stuff that you would recognize, stuff that looks like requests and JSON and Python classes and try, accept and everything.

45:35 - That's pretty cool.

45:36 - It is, here let me actually pull up a little bit of code really quick just to show you all.

45:39 So check it out, we've got our regular code, here's our Flask bit, but if I go to static, there's now a Python folder in static and you can go to the weather API And let me make that bigger for the screen.

45:50 See this code right here?

45:51 It's download a report, type in, it goes to report.

45:54 Has this thing that comes back from calling this URL, turns into JSON, does the--

45:59 - It's hardly any code.

46:01 - That. - Nice.

46:02 - That is running in the browser, in the CPython runtime, all of it locally with no download and no slow startup.

46:09 So. - That's pretty cool.

46:10 - Anyway, I'm gonna do a video on that.

46:12 Yeah, what do you guys think?

46:13 Neat, huh?

46:14 - Yeah, PyScript is, and that's cool what you've done too.

46:17 - PyScript's interesting to me.

46:18 I'm interested to see how that evolves.

46:21 I'm sure, like you said, I think most people are using it maybe from a data science standpoint or waiting for it to mature or whatever, but there's some kind of odd analogs between how React and some of those things got started here.

46:33 Obviously, angled at a different audience, but I think there's some really cool things that could be done with this as you evolve.

46:42 And interesting that you mentioned this on the show today, 'cause if you look in the repo for PyScript, Tailwind is one of their core dependencies.

46:52 - Oh nice, how interesting.

46:53 Yeah, it's all coming together.

46:55 So I'll talk more about it when I release the video later, but I think that this, and the source code is out, it's linking to GitHub, people can check it out and install it.

47:03 It's really neat, and I think it opens the door.

47:06 I can see people writing like a Vue.js wrapper, so you create a Python class that sort of parallels Vue or React or something like that, and you could create really neat stuff in this offline sort of progressive web app mode.

47:17 So we'll see.

47:19 All right, that's it for my extras.

47:20 - Okay, I've got a few.

47:22 The videos for PyCon US 2022 are up.

47:27 So yay, you can watch them now.

47:29 I'll have a link to the show notes, but you can also just look on YouTube and search for PyCon US.

47:35 Yeah, so I'm looking forward to, I've got a whole stack of ones I wanna watch.

47:40 I unfortunately didn't get a chance to make it this year.

47:42 So I'm looking forward to participating in this way.

47:46 Second thing I wanted to bring up is another podcast.

47:49 So there's another Python podcast out there called the Sad Python Girls Club.

47:52 So far they have two episodes.

47:56 The second episode, they interviewed Brett Cannon and it's good.

47:59 They're not actually sad.

48:01 The sad comes from that they used to be emo people when they were young.

48:06 So I thought that was interesting.

48:08 (laughing)

48:10 I listened to a lot of the same music.

48:11 - Nice, all right, congrats to them for starting that.

48:14 That's cool.

48:15 - Yeah.

48:16 Third thing was, is I'm gonna do this publicly to try to get me motivated to finish it, the pytest course.

48:22 So yes, I've started work on the pytest course and it will be through the Talk Python Michael Kennedy thing unless it's really terrible and then he probably won't want to do it.

48:34 (laughing)

48:36 - No, it'll be great, Brian.

48:37 I'm looking forward to it.

48:39 - Yeah, so, man, a couple days ago, I recorded like 20 minutes for the video with the mic off.

48:47 (laughing)

48:50 - I've done that, or two mics on where there's a weird echo, it's offset by 20 milliseconds, and no.

48:56 - Oh, wow.

48:57 - But I'm looking forward to getting that out, 'cause a lot of people have asked for it, so that's in the works.

49:02 - Fantastic.

49:03 - I think that's cool, Brian, you need to finish it.

49:05 We're all a little, none of us write enough tests.

49:09 We need more. We could use the course.

49:11 That's all for me.

49:15 Either of you guys, you got anything else you want to give a shout out to before we wrap it up?

49:18 I guess I better shout out.

49:20 I said I better shout out since you highlighted the cheerleaders earlier.

49:25 I'm pretty sure that was my daughter, Isabel, and a friend, Olivia, and Jess, listening.

49:29 So if they've hung with us this long through Python podcasts, then I better shout out to them.

49:33 Thanks.

49:34 That's cool.

49:36 And I would just say if you're interested in any sort of public company, complicated organizational structures like Tesla or Apple or anything, we have some of them on our website on LexChart.

49:46 And if you want others, just drop us a line and we'll build them.

49:50 Nice. Yeah, that's very cool.

49:51 Yep.

49:52 All right. So we close out with a joke, Brian.

49:54 Yes.

49:55 I wanted to come up with something that I felt was a little bit associated with learning to code and being somewhat beginner, even though what these guys built is not at all beginner, but I know that they've been on that path recently.

50:05 So here we go.

50:07 So this one is an animated GIF of a very frustrated person carrying their computer out, throwing it in the dumpster in the back.

50:14 It says, "Programmers, when they finally fix all their syntax errors in their code just to be confronted with a bug." I don't know about you, but I remember when I was learning C++ I was so happy when I got my complicated code to compile and then I realized, no, that's just the beginning of the hair-pulling part.

50:31 - Yeah.

50:32 - Yeah, it's Ron Swanson.

50:34 (laughing)

50:36 - Yeah, yeah, absolutely.

50:40 All right.

50:42 - Thanks a lot.

50:42 - That's all I got, Brian.

50:43 - Excellent, that was fun.

50:45 - Thanks Ben and Mark for showing up and thanks Michael as always.

50:49 It's been fun.

50:49 - Thank you guys.

50:50 - You bet.

50:51 - Bye everyone. - Bye.

50:52 - Cheers. - Bye.

Back to show page