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


« Return to show page

Transcript for Episode #247:
Do you dare to press "."?

Recorded on Wednesday, Aug 25, 2021.

00:00 Hey there.

00:00 Thanks for listening. Before we jump in on this episode, I just want to remind you that this episode is brought to you by us over at Talk Python Training and Brian through his Pi Test book. So if you want to get hands on and learn something with Python, be sure to consider our courses over at Talk Python Training. Visit them via Python by courses.

00:20 And if you're looking to do testing and get better with Pi test, check out Brian's book at Python BSFM Pi Test.

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 247, recorded August 25. Really? We're almost done in 2021. I'm Brian Arkin.

00:43 I'm Michael Kennedy.

00:44 And I'm Dan Taylor.

00:45 So, Dan, before we jump into things, welcome to the show.

00:49 But but people know kind of who you are. Yeah.

00:52 Thank you. It's great to be here a big fan of the show.

00:55 So I'm Dan Taylor. I'm a program manager manager on our Python team. So I manage a team of program managers that work on our Python developer tools, for example, our Python Support and Visual Studio Code and Visual Studio IDE. And we also manage some of our engagements with the Python community, for example, our sponsorships of Python and the Python Software Foundation.

01:17 That's awesome. You know, something that I thought was pretty interesting? I was just watching a talk from Brett Cannon getting ready for an interview I did on Talk Python with Sling. A lot stuff going on there, but the Talk was only from 2018, and Brett went into detail describing what vs code was. It was like Adam or Sublime and all these things. It means no introduction these days, does it?

01:38 No, it's just been amazing watching just how much it's grown over the past year and become a household name for people, especially in the Python community.

01:48 Well, Michael, how do I keep my computer awake?

01:52 Well, first you make sure it gets 8 hours of sleep a day. You don't overwork it. I know it's work from home, so you might be working on it, playing on it and watching TV. Oh, wait. This is a totally different thing. So I recently was working on this project around some of the courses over Talk Python Training, and I needed to a bunch of video processing and re encoding for take the same videos, but make them smaller.

02:16 So I wrote some really cool Python code to go through and pick the source videos and do all this analysis and reencode it to a bunch of formats. You know, that takes like 5 hours for one of our courses. And if my computer goes to sleep, it's going to take more than 5 hours. I got to go and keep waking the thing up again. Right?

02:34 Well, what can I do? I could go into the settings and say, you know what? Don't do that. Just don't go to sleep right now. But then I forget, who knows?

02:43 It would be cool if just while my Python code was running, it would stay awake, and then it would potentially not stay awake when it was done. Wouldn't that be nice?

02:51 Yeah.

02:52 So I found this cool library called Wake Pie, and the implementation of using this is ridiculously easy.

03:00 You just say from Wake Pie import keep awake, and then you create a context manager with keep awake. Do the stuff you want to do while the computer doesn't go to sleep. Done. That's cool. Yeah, it's super easy. It works cross platform. It works on Windows. It works on Linux. It doesn't really work on Mac OS because there's a bug, but it's supposed to work on Mac OS, which is where I'm running this right now. So that's kind of unfortunate, wouldn't you say?

03:26 It turns out it's one of these strings versus bytes.

03:31 Weirdness.

03:32 So I actually decided this is kind of cool. So what I'm going to do is I'm going to create a PR.

03:38 There's a PR that says it doesn't work on Python three, but you know what? And here's, like the if anyone cares, you get this bytes like object is required, not string. So I submitted a PR. The PR is not yet address or responded to or anything. So if you want to use this for the time being, I can really only on Mac OS.

03:57 Be clear, I can only recommend it off of my branch until you see that PR merch, because it won't work at all. But if you're using Windows or Linux, I think it'll just work straight away. And it's interesting if you actually dig into it, I kind of imagine it would just be doing the same thing. But if you dig into it, like in the Mac version, there's literally a command you can type on. This is awesome. You can type on the terminal. You can type caffeinate that will keep your that will keep your OS from going to sleep. If you just run that on the terminal, if you type, add it'll, keep the display on things like that. I won't let the screen go to sleep. But over on, say, Windows, it does a bunch of tweaking with threads. So what it'll do is like go and set its current thread to be like, continuous system required, display required as a bunch of Bitwise flags, and then over on Linux, it what else uses something completely different. It runs mask and unmask, which I don't actually know what that does. I suspect it keeps it awake.

04:55 So anyway, it's a pretty cool little project.

04:58 It's very simple, but it also solves the problem that I can imagine a ton of people doing data science like things would run into because they want to do a bunch of processing and not have their system go to sleep. What do you all think?

05:10 I think I'm just glad that I know about Caffeinate now, because that's cool.

05:14 Yeah. If you what, you want to keep your Mac awake, you literally just have to go over and type Caffeinate on the terminal. You don't have to have Python or any of those kinds of things. But if you want your Python code to control it, this thing is basically sub pros juggling that man.

05:28 Yeah.

05:28 I can imagine if you're writing code that's scripping websites, looking for updates and things like that, you really wouldn't want your computer to go to sleep. And I always find myself messing around and all the power settings and maxing things out.

05:40 So this is nice.

05:41 Yeah, very cool. Very cool. Awesome. Well, that's it for that one, Brian.

05:44 Cool.

05:45 Off to you.

05:46 What do we got next? We have how to create a great stack overflow question. Actually, this is great.

05:53 A Stack Overflow just sold for $1.4 billion.

05:57 It's quite right. Yeah. Who did it?

06:00 So to do, you know.

06:00 No, I don't remember a company I hadn't heard of.

06:03 How did I miss that, anyway?

06:04 So I don't really actually. Of course, when I Google stuff, I get a bunch of stack overflow answers, and I've utilized it. And I tried to play the whole game for a little while trying to get stack overflow points and stuff. And then I realized, yeah, this just isn't my thing, but it's a thing for a lot of people of answering this.

06:26 But the reason why I brought this up isn't just to get great answers on Stack overflow. But there is a good trick to that. And it's good.

06:33 But it's also if you're asking questions really, from anybody, if you send any sort of expert that, you know, like maybe if you want to ask a pyramid question to Michael or pie this question. For me, these sorts of things are the same topic supply. So let's just jump in. This is from Kevin Markham at Data School.

06:58 Kevin is a great guy. We kind of hang out with them sometimes icons and stuff when we had those. But the punch line of is an article which we'll link to is you need to write a brief introduction and you want to have self contained code examples and then detail the expected results and why you want those results, and then add any other important notes linked to relevant questions, and then also write a title that summarizes the question. He seems sort of obvious. So I'm really glad that Kevin went through kind of an example. So he started with an example that somebody one of his students asked him about Pandas. And the question really was about data frames and filling in missing values. And it had a domain specific thing that somebody was asking him. And then Kevin goes through and rewrite the question as a good stack overflow question.

07:53 And it's night and day. It's like, amazing to see this. So I really encourage people to read the article. But a couple of things that I really love is converting that he doesn't really talk about. But convert the example from any domain specific stuff to a toy example. And that skill of really.

08:14 And that's a good skill to have. Anyway, to say this problem that I'm having in my code, it's really a generic problem. How do I make that using a toy example to describe the problem? And oftentimes actually you can answer your own question once you get it into a toy example and you realize, oh, I'm overthinking it.

08:34 So this is a good first step.

08:37 And so it's a great thing to see, but this is a great example because it's it's like some architecture problem, but then he turns it into colors of toys and it's an easier problem to see. The other thing is making sure that no examples runnable with all the import statements and everything, so somebody can just plop it into their own editor and run it to see if if they can see the same problem.

09:02 And that's good advice. If it's too specific or you don't have the data or it's not complete, you have to speculate rather and then actually verify you can fix the problem or not.

09:13 Right? Yeah. And the part that one of the things that I wouldn't have thought of is linking to other questions because there's a fear I think of moderators and also other people reading it is this is probably if it's simple, it's probably already been answered. What did you already look or whatever.

09:29 And the act of linking to other answers to say this question over here doesn't really it kind of helps me, but it's missing because of this or something. Some reason why the other answer is.

09:44 And that's an interesting take on it. Just so that people don't dismiss you right away is some of them didn't do any research to begin with.

09:52 Yeah, for sure.

09:54 Yeah, it's cool. Usually by the time I get to stack overflow, I'm pretty desperate for help. And so forming really good question. So you get the best answers and is really important. I really like that. Narrowing it down to a reproducible example.

10:07 People can be mean on stack overflow and on Reddit and on YouTube and other places on the internet, but if you show that you've tried, I think that will disarm them somewhat. Alright, I've seen questions like I have this homework question and I can't do my homework. Could anyone help? Can I get that email to you? And like, no, no one can help. No one is here for you. Yes, no one should. But if you have a legitimate problem or you think you found it a legitimate bug or there's just no documentation and it's clear you tried, I suspect that will disarm people. They may still not be able to help you, but at least they won't be mean. Brian, before we move on to the next one, I want to do two quick real time follow ups. So one stack overflow sold to tech giant Process Process. We've all heard of them for $1.8 billion. So that is not messing around. That forum site. Did alright, Joel Spolsky and Jeff Atwood did okay. And then the other one is Unfortunately Dan he Ford out there in the live stream, said he just ran caffeinate three times on his Mac and he can't get it to sleep and it's acting jittery and anxious. I don't really know what we can do about that, but maybe we just go to Tick Dog. What do you think?

11:20 Yeah, totally. Have you ever really wanted to make a quick edit to something you've got in a GitHub repo, but you're kind of stuck with that. That rudimentary feels like you're working with notepad, maybe a little.

11:30 Yeah. So you click the edit, there's little edit thing. You find the file, you edit it, and then you go in there and there's like no help and you just type away. Yeah, I do that. I don't love it, but I do that.

11:40 It feels like you're a notepad. Well, GitHub announced GitHub code Spaces recently, which is a cloud hosted development environments with powerful machines and you have to pay for them. But one of the fun bonus features that they launched at the same time that we only really announced on TikTok and other social media is called GitHub Dev. So you can actually go to any GitHub repo and say, I just want to edit this GitHub repo that I have here. I can just press the key and that will reopen this GitHub repository in something called GitHub Dev. So this is an entirely web browser based version of Es code that's built right into GitHub. It works on any GitHub repo and there's no server behind it. It's serverless. So there's nothing that you need to pay for here.

12:26 And it also has some limited functionality because there's no back end. This is all just front end running in your web browser.

12:33 But what's really cool is that you can come in here and you can add new files. Like, I can go in here and add a new Python file in the File Explorer on the left. I can just click and add a new file and I can work with this more like I'm used to working with a text editor and as I can just say, imports Flask, for example. And because there's support for different extensions that are web enabled that know how to work in this new mode. So we've actually added the Python extension recently in here. So I can actually get some autocomplete from some of the modules. If I say from import Flask, I get the auto complete for that flask object.

13:19 And I can do the typical thing where I can say classic equals name and I can type app.

13:26 And I get all of this ad template filter route all those in the Auto Complete, so I can actually GT a more real editing experience with the productivity things like that that I'm used to when I'm working with text editor. But this is all using the storage file system from the web browsers, local storage, as well as the files from the GitHub repo.

13:49 So for example, if I go in here and just change Hello world Hello Python bytes in this code here, and I hit save on a piece of code, and then I see I've got source control changes here, and it's telling me that I can click on that file and I can actually see a diff of that file side by side. And I can just commit that using the source control panel. And if I add this committee, it will go directly into my GitHub repo.

14:18 So that's pretty cool.

14:20 That's amazing. I do see right below the source control thing, a play debug thing that doesn't work.

14:29 It doesn't there's continue working on code spaces. At that point, you got to get a real machine for if you want to do things like a hosted the real hosted version. Yeah, but we're actually pushing the boundaries of what you can do in these web versions in some interesting ways. So you can get basic syntax highlighting as you saw Auto complete, but there's no Python interpreter. So when I go to definition, say want to go to definition on this Flask module? It just brings up type in the type in that we have for the type in the still.

15:01 Okay, though, it's still better than what you get with a normal editor.

15:05 Yeah, it's pretty cool. One kind of bonus thing I want to throw in here is that if you go to the extensions tab, you'll be able to search and you'll see which extensions are web enabled. And one of the fun ones that somebody on our team put out is this Vs code Iodide one.

15:21 So if you actually open a Jupiter notebook, you can run a little bit of Python code from these cells here using Iodide. So that's pretty neat.

15:30 Wow.

15:31 So this is web assembly for the wine that's GitHub Dev.

15:35 I think it's really cool how much more you can do right from the browser within GitHub. We're excited to see what you know about this.

15:43 I didn't, and I was just playing with it in the background on my own rep.

15:48 I was looking through the extensions and maybe know off the top of your head. Dan, can I get the mode in this extension?

15:57 You'll see which ones are.

16:00 So if they're highlighted here and not grayed out. So this is an extension works so you can see which ones are available. It says available in Vs code.

16:10 We just made Brian's Day. There's a couple of options.

16:13 Yeah, yeah, I just can't use any editor without the mode anymore.

16:17 My brain just doesn't work without do you go to or like other Editors or anything like that.

16:23 What's that?

16:24 How do you use Google Docs or some other editor?

16:26 I pasted into that after I've written stuff in somewhere else.

16:32 Nice. Dan first obvious. I was on my GitHub repo and I'm like, let me just hit dot because it seems like that's too simple. But I'll try it and became an editor. I'm like, oh my God, this is awesome. And then I went into the settings and I put it into dark mode and I changed the font size and all the font family. And I'm like, oh, this is.

16:50 This is nice. Like, this is really cool.

16:52 Yeah, I'm excited about it. Let me throw one more bonus in here.

16:56 So if I change to edit this Jupiter notebook cell here, and if I go into the diff of if I go into the source control panel after editing the stupider notebook sell, I can actually see a real diff side by side with those cells. So that's something cool you can do without having to install a full editor and things locally.

17:21 Very cool. And it's a nice dip of the cell contents. Not like the JSON crazy. If you get the left left.

17:29 Right with red green ad remove and outputs are squash. You're not seeing a bunch of if you dip a notebook, you'll see a bunch of XML and JSON being removed and added. This is more that rich.

17:42 Take all of the various encoding language storage formats and then jam them all together and then dip that. That's fun. No, this is awesome. This is a great view.

17:52 Click it. Let me use it.

17:53 Indeed.

17:54 So one of the things that I don't really edit and get very much what happens like once you're done, does it create a merge request or just edited in place?

18:03 Or it makes a commit directly to the repository so I can just throw that right in there.

18:10 So you have to obviously you have to have permissions. You have to be one of the people that can commit directly to that bridge, right?

18:17 Yeah, this is great. I was so delighted when I saw it. So I'm going to definitely use this.

18:22 Nice.

18:23 Alright, Brian, my up on the next one. You are right on. Let's move on to it. Okay, I'm resisting the temptation. Hit dot and play around with the wake pie instead.

18:34 Let me take you over here. So we go to Python. That's not Python bites close, but not exactly.

18:40 They don't even want it. I type com. I've never hold on to it. No, that's our domain. So we're live streaming right now. By the way, if you did notice if you go over here, notice I've got Firefox that I'm using and it has this little shield and almost anything you go to. And I want to go to a new site. But let's go to CNN and you come over here and you'll see a bunch of stuff up here.

19:03 Getting blocked, like social media trackers tracking on, like, look at that as a ridiculous amount of gross. Google Analytics, Google Tag services, Rubicon Project, US East, apparently that's bad, right? So I've done a lot of work. Get us away from retargeting tracking, and we have no known trackers. Now I'm running a VPN, which probably blocked a bunch of the ones off of CNN.

19:29 That was the one that got through the blocking and stuff. So it's really nice to not have all that stuff and let people come visit the site and know that we're not retargeting them. We're not tracking them. We're not doing stuff. We're just giving them a podcast or same thing over on talk by the training or talk Python or whatever you go there, you get the content, we offer things like a podcast with ads that people can take. And that's enough. We don't need to follow you around for all sorts of creepy reasons, right? The drawback is we don't have a lot of analytics, right? We get a sense about download numbers and things like that, but we can't report, like, well, in the last hour since we talked about this thing, here's, the traffic away, or would we?

20:14 So junction apps over on Twitter said, hey, you know what had you going on and on about the retargeting of all these places and how you dropped it? Have you heard about Go access? I have either of you heard about this thing? No, I haven't either. But check it out is super cool.

20:32 So what it is is it is a Google Analytics like service that you install on your server.

20:38 And what it does if this image in a tab so it doesn't go away. What it does is it looks and tails your logs and gives you real time analytics on your logs rather than by looking at going through JavaScript and hooking into people's browsers. So no tracking, none of that stuff. But you can come over here and in your terminal, run it and get a real time view of your traffic, your visitors, all the kind of stuff you would expect from Google Analytics visually as a graph like thing in your terminal.

21:10 Interesting.

21:11 It's really cool.

21:12 What kind of information are you getting?

21:14 Well, probably the easiest way to find out is they have a web view and have the terminal view. The web view is really generate a HTML file and then just request it. So there's not, like, a web server type thing, but you go over here and click it says here, I'll give you the features real quick, then open up the demo. It says Fast real time millisecond based on latency updates written and see only uses in cursors dependencies works on almost all the formats. Engine X, amongst the others.

21:41 Just set the log format and run it on your log. Got the terminal and the UI, the web UI bit. So if you go over here, you can see, like, look at this off of just the log files. So you can see things like here, I'll pull them up so you can go over and say, well, what are the referring URLs?

21:57 Let me make that small so you can kind of see here. Unfortunately, here's the referring URLs you can see in this example, they were, you know, shop, internet, whatever. At least it's a fake site. But you can come over here and actually see graphs as well as, like, grids and pages, stuff like the Google Analytics. But if you run a site and you can point this against your logs and get real time information in the terminal, or as in this web view, yeah, it's pretty neat.

22:25 And so do you have to install anything, or do you just run this and it finds the logs on your system and pulls it all together?

22:32 Yeah, you do have to install.

22:34 Let's see here.

22:35 So there's a getting started. And it says the way to get started, probably to use a package manager for your Linux machine. If you're running on Linux, or you can get a Docker image and you run it, and then what you do is you just simply run the command against your log file and tell it what format and boom, off it goes. So you could set it up as like a Cron job or something that will then generate the HTML file. And you could just refresh that however often you want to or run the terminal one.

23:05 You could run it once a day, too. And you say you don't need to save the report.

23:10 Exactly.

23:11 Yeah.

23:11 You don't need real time, real time. You need just sort of house the day going something like that. How was yesterday?

23:17 Right. So one of the things that I use information like this about is I don't really want to track users. I don't care about individual users, but I do want to know, like, I've got putting up different content on my blog or on a podcast. Which ones?

23:32 Which ones are resonating with people?

23:35 Maybe do more of that.

23:38 So you can see, like, there's a little bunch of options here, burning side host requested files they call it, but it's really just URLs.

23:48 So you go over here and this would tell you sort of the traffic across your various pages. Right. So this would be like your list is requested file URL or the one you want.

23:59 Yeah.

24:00 So anyway, I haven't set this up yet, but it looks pretty neat, and it could be worth checking out. And I guess even you could download your logs and not install it on your server if you really wanted. Right. You want this view, you don't actually want to put it on your server because putting stuff on the server so you could download it and then just run against your logs locally.

24:20 And you might be uploading your logs to a storage account somewhere to on a Cron job.

24:25 Yeah, exactly. You could push the logs out instead of running it. There a bunch of cool as to use this, but if people are running web apps and they want more visibility into it, this looks like a cool thing. So thanks, junction first, send that over right after you.

24:38 Brian, I want to talk about keywords a little bit. So this was a topic recommended by somebody named Blaze. Blaze, I think so. There's a package called Km.

24:53 It's actually a collection of collection of pieces of software, but it's that we're linking to the Cam Cave firmware.

25:01 So this is firmware for computer keyboards written and configured in circuit Python. So got super excited about this. I'm still kind of excited about it. The gist of it is you've got if you've got a keyboard that runs a run circuit Python, and it's powerful enough to run to handle your keyboard and stuff. So there's a couple of tips in there. There's a couple available through eight Fruit of different boards that would work. We'll get into the details a little bit more, but basically you can configure a keyboard with a single file, single Python file.

25:44 It controls both split keyboards, two piece keyboards, and single keyboards.

25:49 You can hook up macros things like chainable macros to, so you can have key sequences built into one one key, or you can hook it up. So that a key hitting multiple times. You can hit, like, a particular key three times in a row, and you'll have one action versus something else. So even controlling under Glow and LEDs and back lights and all that sort of stuff totally would be fun. I want to use this. I don't know how. It seems like a lot of work, though.

26:21 We're linking to the project, and there's some information here. There's some guides on how to get started, and then we're also going to run. I found somebody that ran this, and he's got a video that walks through doing it. But the gist of it is there aren't any keyboards that do this right away. So you've got to take an existing keyboard, rip out the existing circuit board, and replace it with one of the 80 Fruit board in Fruit boards, and then reprogram it. So if you're the kind of person that's okay with ripping the the circuit board out of your Kateboard and replacing it with something else, that'd be great. And I actually wouldn't mind doing this. I think that'd be fun, but I'd kind of like to know which keyboards I can do this with and which ones I can't. I know there's a huge list of keyboards out there, but even just a couple, like starter kits would be great to hear.

27:13 It really works well with this one. And here's where the circuit Python board fits in there easily rather than it doesn't really go back in. Yeah.

27:23 So one of the reasons why I'm bringing this up is I love somebody from Adafruit or from anybody working on circuit Python. Or I came M team or somebody to maybe put a couple more tutorials out to just say, hey, this is how you do it for. I'd love it to have, like, off the shelf full keyboard, even if it's small or whatever it said. Okay, here's how you do it. You pull this circuit board out, put this other one in it's like $40 on a fruit, and there you go. You can try it. And here's a sample of file that you would run. It run just a normal keyboard usage, and now you can customize it, because just getting back to a workable keyboard seems already like a lot of work, but it still looks fun. I'd love to be able to hack a keyboard with Python.

28:13 Very cool, Dan. What kind of keyboard do you use?

28:17 Well, I'm a big fan of the thin keys, right? The very light travel keys. But I got the economic keyboard, so thin ergonomic Logitech not into the I.

28:31 I've got the Microsoft Sculpt ergonomic.

28:33 Which I absolutely love. I know Brian's got even more exotic stuff. He's running over there.

28:39 I don't know if I can get mine up here.

28:40 I'll see the camera it's mounted to the is my junk, too.

28:46 I've got a Kinesis.

28:47 Yeah, the Kinesis inverted ones. Those are super interesting. What I would like to see would be some keyboard manufacturer saying we're shipping a keyboard to you and you can program it with Python and basically do this for you as a package thing and just build it out of these components. That'd be fantastic.

29:05 Yeah, it'd be great.

29:06 Well, I think it'd be fun with everyone decking out their home offices these days. If you could do a little bit of magic light show while you're presenting or talking on a call, that would be really cool.

29:17 That would be fantastic.

29:18 Yeah.

29:18 Hey, Brett. Cannons out there in the live stream.

29:21 Dan, you may have heard of this guy.

29:23 Pablo Delgado has programme the keyboard RGB lights to color code the build bot status for C Python. I don't know which library uses that's awesome. So it's green if everything's good, but it turns red of CI fails or something like that. That's awesome, Brett. Thanks for sharing.

29:41 That'd be cool. You know, I never really. I mean, when I first saw that the LEDs under the keyboard, I thought, yeah, gamers like it, but I don't think I would probably have use for it, but now I'm jealous. I want light up things on my keyboard.

29:55 It'd be fun, especially if you could program them. Right. Like this example here, my mouse sits here in pulsates and changes color.

30:03 But because it's on a Mac, the software doesn't work and I can't do anything with it, so it's. It just annoys me there. It's good mouse otherwise.

30:10 But anyway, so is it a Windows only thing or what?

30:13 No, the mouse is perfect off on Mac, but the software that lets you customize it and do interesting things to the colors doesn't work on the Mac.

30:22 Me.

30:22 Super lame. Super lame. Alright, what is not lame is this last thing that Dan has got here because this thing has been blowing up on Twitter all of a day old with, like 2000 get up stars.

30:34 And I was like, oh, this has got to be covered. And then Daniel were on it.

30:37 Yeah, I just saw it yesterday and I was like, I have to talk about this. So I know that when I built web apps in the past, one of the big frustrations I have is that when you want to add something new to your database, you need to add it to the SQL queries. You need to add something to the back end code. You need to add a piece to the API that the returns that new object to users, and then in your client code, you need to consume it. So there's all this repetition that you're doing across your web app every time you need to make a change to your data or add a new object.

31:10 And that's very error prone as well.

31:13 And so things like sequel alchemy you can use to write code that interacts with your database. And then things like fast API. You can use Pedantic to return models to your users to your APIs. But then now we had this thing where you have sequel alchemy models and Pedantic models, and then you're translating back and forth between them. And so Sebastian Ramirez, who just released yesterday this new Sequel model library, which looks just awesome because it actually combines the schema for talking to the database and speaking to your API into one schema object that you write. So what's really cool about this is that so the way you work with this is that you define your objects. For example, he's got in the GitHub repo this hero class with an ID name, secret name, Age. And it's got some of the sequel alchemy type things like it's your primary key.

32:18 The ID is optional, but it's default on its primary key. So what's really cool about this class is both a sequel alchemy model and a bit antic model. I don't know how he did that. He said there's some magic that's going on behind the scenes.

32:33 And so what's really cool is that you can use this to instantiate your database.

32:38 So you've got this Hero class.

32:41 You can create objects in the database by going, 01020 three equals hero bracket and pass the name secret name all the fields to the object.

32:52 And you can also return those same objects.

32:57 You can use that same Hero class and use it in your fast API. So you can accept hero objects.

33:03 You can return hero objects. And so you write that one schema and you use it in multiple Places what you have on the screen here.

Back to show page