WEBVTT

00:00:00.001 --> 00:00:03.900
Hey there, thanks for listening. Before we jump into this episode, I just want to remind you

00:00:03.900 --> 00:00:09.740
that this episode is brought to you by us over at Talk Python Training and Brian through his pytest

00:00:09.740 --> 00:00:15.020
book. So if you want to get hands-on and learn something with Python, be sure to consider our

00:00:15.020 --> 00:00:21.900
courses over at Talk Python Training. Visit them via pythonbytes.fm/courses. And if you're

00:00:21.900 --> 00:00:27.500
looking to do testing and get better with pytest, check out Brian's book at pythonbytes.fm slash

00:00:27.500 --> 00:00:32.660
pytest. Enjoy the episode. Hello and welcome to Python Bytes, where we deliver Python news and

00:00:32.660 --> 00:00:39.600
headlines directly to your earbuds. This is episode 247, recorded August 25th. Really? Oh,

00:00:39.600 --> 00:00:46.080
we're almost done. In 2021, I'm Brian Okken. I'm Michael Kennedy. And I'm Dan Taylor. So Dan,

00:00:46.080 --> 00:00:52.520
before we jump into things, welcome to the show. But can you let people know kind of who you are?

00:00:52.520 --> 00:00:58.220
Yeah, thank you. It's great to be here. A big fan of the show. So I'm Dan Taylor. I'm a program

00:00:58.220 --> 00:01:05.180
manager manager on our Python team. So I manage a team of program managers that work on our Python

00:01:05.180 --> 00:01:10.580
developer tools. For example, our Python support and Visual Studio Code and Visual Studio IDE. And

00:01:10.580 --> 00:01:15.800
we also manage some of our engagements with the Python community. For example, our sponsorships of

00:01:15.800 --> 00:01:20.240
PyCon and the Python Software Foundation. That's awesome. You know something, Dan, I thought was

00:01:20.240 --> 00:01:25.080
pretty interesting. I was just watching a talk from Brett Cannon, getting ready for an interview I did

00:01:25.080 --> 00:01:31.360
on Talk Python with Lenga. A lot of stuff going on there. But the talk was only from 2018. And Brett

00:01:31.360 --> 00:01:36.640
went into detail describing what VS Code was. I was like, Adam or Sublime and all these things.

00:01:36.640 --> 00:01:43.300
It needs no introduction these days, does it? No, no. It's just been amazing watching just how much

00:01:43.300 --> 00:01:47.460
it's grown over the past year and become a household name for people, especially in the Python community.

00:01:47.940 --> 00:01:51.680
Cool. Well, Michael, how do I keep my computer awake?

00:01:51.680 --> 00:01:57.580
Well, first, you make sure it gets eight hours of sleep a day. You don't overwork it. I know it's

00:01:57.580 --> 00:02:02.340
work from home. So you might be working on it, playing on it and watching TV. Oh, wait, this is not this is a

00:02:02.340 --> 00:02:07.980
totally different thing. So I recently was working on this project around some of the courses over at

00:02:07.980 --> 00:02:14.520
Talk Python training. And I needed to do a bunch of video processing and reencoding for like, take the same

00:02:14.520 --> 00:02:19.680
videos, but make them smaller. So I wrote some really cool Python code to go through and take

00:02:19.680 --> 00:02:24.820
the source videos and do all this analysis and reencode it into a bunch of formats. You know,

00:02:24.820 --> 00:02:30.900
that takes like five hours for one of our courses. And if my computer goes to sleep, it's going to take

00:02:30.900 --> 00:02:35.960
more than five hours. I got to go and like keep waking the thing up again. Right. Well, what can I do?

00:02:36.000 --> 00:02:40.540
I could go into the settings and say, you know what? Don't do that. Just don't go to sleep right

00:02:40.540 --> 00:02:46.440
now. But then maybe I'll forget. Who knows? It would be cool if just while my Python code was running,

00:02:46.440 --> 00:02:51.600
it would stay awake and then it would potentially not stay awake when it was done. Wouldn't that be nice?

00:02:51.600 --> 00:02:58.900
Yeah. Yeah. So I found this cool library called WakePy and the implementation of using this is

00:02:58.900 --> 00:03:04.880
ridiculously easy. You just say from WakePy import, keep awake. And then you create a context manager

00:03:04.880 --> 00:03:09.600
with keep awake, do the stuff you want it to do while the computer doesn't go to sleep. Done.

00:03:09.600 --> 00:03:15.800
That's cool. Yeah. It's super easy. It works cross-platform. It works on windows. It works

00:03:15.800 --> 00:03:20.480
on Linux. It doesn't really work on macOS because there's a bug, but it's supposed to work on macOS,

00:03:20.640 --> 00:03:24.700
which is where I'm running this right now. So that's kind of unfortunate. Wouldn't you say?

00:03:24.700 --> 00:03:35.800
It turns out it's one of these strings versus bytes weirdness. So I actually decided this is kind

00:03:35.800 --> 00:03:40.240
of cool. So what I'm going to do is I'm going to create a PR. There's a PR that says it doesn't

00:03:40.240 --> 00:03:45.200
work on Python three, but you know what? And here's like the error. If anyone cares, you get this,

00:03:45.200 --> 00:03:49.620
a bytes like object is required, not string. So I submitted a PR. The PR is

00:03:49.620 --> 00:03:55.500
not yet addressed or responded to or anything. So if you want to use this for the time being,

00:03:55.500 --> 00:04:00.840
I can really only on macOS, to be clear, I can only recommend it off of my branch until you see

00:04:00.840 --> 00:04:05.780
that PR merge because it won't work at all. But if you're using windows or Linux, I think it'll just

00:04:05.780 --> 00:04:09.960
work straight away. And it's interesting if you actually dig into it, I kind of imagined it would

00:04:09.960 --> 00:04:14.960
just be doing the same thing. But if you dig into it, like in the Mac version, there's literally a

00:04:14.960 --> 00:04:19.040
command you can type on. This is awesome. You can type on the terminal. You can type

00:04:19.040 --> 00:04:24.800
caffeinate. That will keep your OS from going to sleep. If you just run that on the terminal.

00:04:24.800 --> 00:04:31.940
If you type a dash D, it'll keep the display on, things like that. It won't let the screen go to

00:04:31.940 --> 00:04:37.480
sleep. But over on say Windows, it does a bunch of tweaking with threads. So what it'll do is like

00:04:37.480 --> 00:04:44.360
go and set its current thread to be like continuous, system required, display required as a bunch of

00:04:44.360 --> 00:04:50.040
bitwise flags. And then over on Linux, it uses what else? It uses something completely different.

00:04:50.040 --> 00:04:55.260
It runs mask and unmask, which I don't actually know what that does. I suspect it keeps it awake.

00:04:55.260 --> 00:05:01.820
So anyway, it's a pretty cool little project. It's very simple, but it also solves the problem that I

00:05:01.820 --> 00:05:07.300
can imagine a ton of people doing data science-y like things would run into because they want to do a

00:05:07.300 --> 00:05:10.420
bunch of processing and not have their system go to sleep. What do you all think?

00:05:10.420 --> 00:05:14.600
I think I'm just glad that I know about caffeinate now because that's cool.

00:05:14.600 --> 00:05:19.460
Yeah. If you want to keep your Mac awake, you literally just have to go over and type caffeinate

00:05:19.460 --> 00:05:23.160
on the terminal. You don't have to have Python or any of those kinds of things. But if you want your

00:05:23.160 --> 00:05:28.160
Python code to control it, this thing is basically subprost juggling that command.

00:05:28.160 --> 00:05:33.560
Yeah. I can imagine if you're writing code that's scraping websites, looking for updates and things like

00:05:33.560 --> 00:05:37.460
that, you really wouldn't want your computer to go to sleep. And I always find myself messing around

00:05:37.460 --> 00:05:41.040
and all the power settings and maxing things out. Exactly. So this is nice.

00:05:41.040 --> 00:05:44.580
Yeah. Yeah. Very cool. Very cool. Awesome. Well, that's it for that one, Brian.

00:05:44.580 --> 00:05:46.040
Cool. Off to you.

00:05:46.040 --> 00:05:52.120
What do we got next? We have, oh, how to create a great stack overflow question. Actually, this is,

00:05:52.120 --> 00:05:58.740
this is great. Yeah. Stack overflow just sold for like $1.4 billion. It's quite the site.

00:05:58.740 --> 00:06:00.760
Yeah. Who did it sell to? Do you know?

00:06:00.760 --> 00:06:03.040
No, I don't remember. It's a company I hadn't heard of.

00:06:03.100 --> 00:06:10.080
I didn't miss that. Anyway. So I, you know, I don't really, I actually, of course, when I Google

00:06:10.080 --> 00:06:15.940
stuff, I get a bunch of stack overflow answers and I've utilized it. And I had, I like tried to play

00:06:15.940 --> 00:06:20.080
the whole game for a little while of like trying to get stack overflow points and stuff. And then I

00:06:20.080 --> 00:06:25.840
realized, yeah, this just isn't my thing, but it's a thing for a lot of people of like answering this.

00:06:26.340 --> 00:06:31.200
But the reason why I brought this up isn't just to get great answers on stack overflow, but there is a

00:06:31.200 --> 00:06:37.040
good trick to that and it's good. But it's also, if you're asking questions really from anybody, if you,

00:06:37.040 --> 00:06:43.260
if you send a, any sort of expert that, you know, like maybe if you want to ask a pyramid question to

00:06:43.260 --> 00:06:50.560
Michael or a pie test question for me, these sorts of things are, this, this is a, this, the same,

00:06:50.760 --> 00:06:58.780
same topics apply. So let's just jump in. This is from Kevin Markham at data school. Kevin's a great

00:06:58.780 --> 00:07:04.920
guy. We've kind of hang out with him sometimes at picons and stuff when we had those, but the punchline

00:07:04.920 --> 00:07:12.560
of his article, which we'll link to is you need to write a brief introduction and you want to have

00:07:12.560 --> 00:07:18.880
self-contained code examples and then detail the expected results and why you want those results.

00:07:18.880 --> 00:07:24.880
And then add any other important notes linked to relevant questions. And then also write a title

00:07:24.880 --> 00:07:31.020
that summarizes the question. These all seem sort of obvious. So I'm really glad that Kevin went through

00:07:31.020 --> 00:07:36.200
kind of an example. So he started with an example that somebody, one of his students asked him about

00:07:36.200 --> 00:07:42.160
pandas. And the question really was about data frames and filling in missing values. And it had

00:07:42.160 --> 00:07:48.960
a domain specific thing that is somebody was asking him. And then, then Kevin goes through and

00:07:48.960 --> 00:07:55.820
rewrites the question as a good stack overflow question. And it's night and day. It's like amazing

00:07:55.820 --> 00:08:02.440
to see this. So I really encourage people to read the article, but what a couple of things that I really

00:08:02.440 --> 00:08:09.740
love is converting that he doesn't really talk about, but convert the example from any domain

00:08:09.740 --> 00:08:16.540
specific stuff to a toy example. And that skill of really, and that's a good skill to have anyway,

00:08:16.540 --> 00:08:22.840
is to, to say this problem that I'm having in my code, it's really a generic problem. How do I make

00:08:22.840 --> 00:08:28.860
that using a toy example to describe the problem? And oftentimes actually you can answer your own

00:08:28.860 --> 00:08:34.380
question. Once you get it into a toy example and you realize, Oh, I'm just, I'm not, I'm overthinking it.

00:08:34.480 --> 00:08:41.280
So this is a good first step. and so this is, that's a great thing to see, but, this is a great

00:08:41.280 --> 00:08:46.940
example. Cause it's a, it's like some architecture problem, but then he turns it into colors of toys.

00:08:46.940 --> 00:08:53.060
and it's a, it's an easier problem to see. The other thing is making sure that two examples runnable

00:08:53.060 --> 00:08:58.220
with all the import statements and everything. So somebody can just flop it into, their own editor

00:08:58.220 --> 00:09:04.020
and run it to see, you know, if, if, if, if they can see the same problem and see if they can figure

00:09:04.020 --> 00:09:08.760
out. That's good advice. If it's too specific or you don't have the data or it's not complete,

00:09:08.760 --> 00:09:13.960
you have to speculate rather than actually fix, you know, verify you can fix the problem or not. Right.

00:09:13.960 --> 00:09:19.120
Yeah. And the part that I, one of the things that I wouldn't have thought of is linking to other

00:09:19.120 --> 00:09:24.280
questions because there's a fear, I think of moderators and also other people reading it is,

00:09:24.400 --> 00:09:28.260
this is probably our, it's, if it's simple, it's probably already been answered. What did you

00:09:28.260 --> 00:09:35.120
already look or whatever? And the act of linking to other answers to say this question over

00:09:35.120 --> 00:09:42.420
here doesn't really, it kind of helps me, but it's missing because of this or something, some reason

00:09:42.420 --> 00:09:49.020
why the other answers, the, and that that's an interesting take on it just to, so that people

00:09:49.020 --> 00:09:53.180
don't dismiss you right away as somebody that didn't do any research to begin with. So.

00:09:53.700 --> 00:09:54.320
Yeah, for sure.

00:09:54.320 --> 00:09:59.020
Yeah. It's cool. Usually by the time I get to stack overflow, I'm pretty desperate, for help.

00:09:59.020 --> 00:10:03.900
And so forming a really good question. So you get the best answers and, is, is really important.

00:10:03.900 --> 00:10:07.260
I really like that narrowing it down to a reproducible example.

00:10:07.260 --> 00:10:12.960
Yeah. And people can be mean on stack overflow and on Reddit and on other, and on YouTube and other

00:10:12.960 --> 00:10:18.800
places on the internet. But if you show that you've tried, I think that will disarm them somewhat.

00:10:18.800 --> 00:10:19.360
Totally.

00:10:19.560 --> 00:10:22.900
Right. I mean, I've seen questions like I have this homework question and I can't do

00:10:22.900 --> 00:10:28.800
my homework. Could anyone help? And I get that email too. And like, no, no one can help. No

00:10:28.800 --> 00:10:33.060
one wants to do your homework for you. Yeah. So no one should, but if you have a legitimate

00:10:33.060 --> 00:10:38.780
problem or you think you found it a legitimate bug or there's just no documentation and it's

00:10:38.780 --> 00:10:43.060
clear you've tried, I suspect that'll disarm people. They may still not be able to help you,

00:10:43.120 --> 00:10:46.500
but at least they won't be mean. Hey, Brian, before we move on to the next one, I want to

00:10:46.500 --> 00:10:53.720
do two quick real-time follow-ups. So one stack overflow sold to tech giant process process.

00:10:53.720 --> 00:11:00.680
We've all heard of them for $1.8 billion. So that is not messing around. they, that's

00:11:00.680 --> 00:11:06.260
that forum site did all right. Jill Spolsky and Jeff Atwood did okay. And then the other

00:11:06.260 --> 00:11:10.980
one is, unfortunately Dan Heford out there in the live stream said he just ran caffeinate

00:11:10.980 --> 00:11:15.040
three times on his Mac and he can't get it to sleep and it's acting jittery and anxious.

00:11:15.040 --> 00:11:19.880
So, I don't really know what we can do about that, but maybe we just go to TikTok. What do you

00:11:19.880 --> 00:11:24.740
think? Yeah, totally. So have you ever, have you ever really wanted to make a quick edit to

00:11:24.740 --> 00:11:28.640
something you've gotten a GitHub repo? but you're kind of stuck with that, that rudimentary

00:11:28.640 --> 00:11:32.620
feels like you're working with notepad maybe a little. Yeah. So you click the edit, there's a little

00:11:32.620 --> 00:11:36.380
edit thing. You find the file, you edit it, and then you go in there and there's like no help. And

00:11:36.380 --> 00:11:40.660
you just type away. Yeah, I do that. I don't love it, but I do that. It feels like

00:11:40.660 --> 00:11:46.860
your notepad. Well, GitHub announced, GitHub code spaces, recently, which is a cloud

00:11:46.860 --> 00:11:50.640
hosted development environments with powerful machines and you have to pay for them. But one

00:11:50.640 --> 00:11:55.880
of the fun bonus features that they launched at the same time that we only really announced on TikTok

00:11:55.880 --> 00:12:03.380
and other social media, is, is called GitHub.dev. So you can actually go to any, GitHub repo

00:12:03.380 --> 00:12:09.240
and say, I just want to edit this GitHub repo that I have here. And I can just press the dot key

00:12:09.240 --> 00:12:15.440
and that will reopen this, this GitHub repository in something called GitHub.dev. So this is an

00:12:15.440 --> 00:12:20.540
entirely, web browser based version of VS Code that's built right into GitHub. It works on any

00:12:20.540 --> 00:12:25.420
github repo. and there's no server behind it. It's serverless. So there's nothing that you need

00:12:25.420 --> 00:12:30.620
to pay for here. and so it also has some limited functionality because there's no backend. This is all

00:12:30.620 --> 00:12:37.540
just, front end running in your web browser. but, what's really cool is that, you can

00:12:37.540 --> 00:12:43.140
come in here and, and you can edit, you can add new files. Like I can go in here and add, you know,

00:12:43.140 --> 00:12:47.940
a new Python file, in the file explorer on the left, I can just click and add a new file and I can

00:12:47.940 --> 00:12:54.180
work with this more like I'm used to working with a text editor. and as I can just say imports,

00:12:54.180 --> 00:13:02.040
flask, for example, and because we've, there's support for different extensions that are

00:13:02.040 --> 00:13:06.380
web enabled that, that know how to work in this new mode. So we've, we've actually added the Python

00:13:06.380 --> 00:13:13.800
extension recently in here. So I can actually, get some autocomplete from, from, some of the

00:13:13.800 --> 00:13:19.560
modules. So if I say from flask import, flask, I get the autocomplete for that flask object.

00:13:19.760 --> 00:13:27.120
And I can do the typical thing where I can say flask equals name and I can type app dot,

00:13:27.120 --> 00:13:32.400
and I get, all of this, you know, add template filter route, all those in the autocomplete. So I

00:13:32.400 --> 00:13:39.040
can actually get a, a more real editing experience with that productivity, things like that,

00:13:39.040 --> 00:13:44.500
that I'm used to when I'm working with text editor, but this is all using the storage file system

00:13:44.500 --> 00:13:49.740
from the web browsers, local storage, as well as the files from the GitHub repo.

00:13:49.740 --> 00:13:56.380
so if, for example, if I go in here and just, change hello world, hello Python bytes,

00:13:56.380 --> 00:14:02.800
um, in this code here, and I hit save, on a piece of code, and then I see I've got source control

00:14:02.800 --> 00:14:08.240
changes here and it's telling me that I can click on that file and I can actually see a diff of that

00:14:08.240 --> 00:14:13.700
file, side by side. And I can just, commit that using the source control panel. And if I,

00:14:13.700 --> 00:14:19.440
if I add this commit, it'll go directly into my GitHub repo. so that's pretty cool.

00:14:19.720 --> 00:14:25.960
So a lot of the, that's amazing. I do see right below the source control thing, a, a play debug

00:14:25.960 --> 00:14:31.580
thing. so, so that doesn't, that doesn't work yet. Does it? Yeah. So that, that's what there's

00:14:31.580 --> 00:14:35.900
like continue working on Codespaces at that point. You got to get a real machine for, if you want to

00:14:35.900 --> 00:14:40.900
do things like the hosted, the real hosted version. Yeah. Yeah. But, but there is some, we're actually

00:14:40.900 --> 00:14:44.860
pushing the boundaries of what you can do in the, in these web versions in some interesting ways. So you

00:14:44.860 --> 00:14:50.220
can get basic syntax highlighting as, as you saw autocomplete. but there's no Python interpreter.

00:14:50.220 --> 00:14:56.200
So when I go to definition, say, I want to go to definition on this flask module, it just brings up

00:14:56.200 --> 00:15:01.760
type hints, the pipe, the type hints that we have. I see the type shed type hints. Okay. It's still okay

00:15:01.760 --> 00:15:06.800
though. It's still better than like what you get with the normal editor. Yeah. It's pretty cool. One,

00:15:06.800 --> 00:15:12.460
one kind of bonus thing I want to throw in here is that, so if you go to the extensions tab,

00:15:12.460 --> 00:15:17.540
you'll, you'll be able to search and you'll see which extensions are web enabled. And one of the fun

00:15:17.540 --> 00:15:23.300
ones that, somebody on our team put out is this VS Code pyiodide one. so if you actually open a

00:15:23.300 --> 00:15:29.100
Jupyter notebook, you can, you can run a little bit of Python code from these cells, here, using

00:15:29.100 --> 00:15:34.620
pyiodide. So that's pretty neat. Oh, wow. So this is WebAssembly for the win. Yeah. So that's

00:15:34.620 --> 00:15:39.900
github.dev. I think it's a really cool how much more you, you can do, right from the browser

00:15:39.900 --> 00:15:44.080
within, within GitHub. I'm excited to see where this goes. Ryan, did you know about this? I didn't.

00:15:44.080 --> 00:15:49.340
And I was just playing with it in the background on my own, repo. I was, I haven't, I was

00:15:49.340 --> 00:15:54.720
looking through the extensions and maybe, you know, off the top of your head, Dan, can I get the Vim

00:15:54.720 --> 00:16:01.800
mode in this extension? well, if you, you'll see which ones are, so if they're, if they're

00:16:01.800 --> 00:16:06.660
highlighted here and not grayed out, so the, this Vim extension works, so you can, you

00:16:06.660 --> 00:16:11.680
can see which ones are available. It says available in VS Code Web. You just made Brian's day. There's

00:16:11.680 --> 00:16:17.240
a couple of Vim options. Yeah. Yeah. I can't, I just can't use any editor without Vim mode anymore.

00:16:17.240 --> 00:16:22.640
Yeah. My brain just doesn't work without. How do you use Google Docs or like other editors or

00:16:22.640 --> 00:16:28.000
anything like that? What's that? How do you use Google Docs or some other editor? I paste into

00:16:28.000 --> 00:16:34.680
that after I've written the stuff in some, in somewhere else. Nice. Dan, when I first saw

00:16:34.680 --> 00:16:39.060
this, I was, I was on my GitHub repo and I'm like, Oh, let me just hit dot because it seems

00:16:39.060 --> 00:16:42.860
like that's too simple, but I'll try it. And then boom, it came an editor. I'm like, Oh my

00:16:42.860 --> 00:16:46.900
God, this is awesome. And then I went into the settings and I put it into dark mode and I

00:16:46.900 --> 00:16:51.520
changed the font size and all the font family. And I'm like, Oh, this is, this is nice. Like

00:16:51.520 --> 00:16:55.620
this is a really cool. Yeah. I'm, I'm excited about it. Let me throw one more bonus in here.

00:16:55.620 --> 00:17:05.660
So if I change this to say, edit this, a Jupyter notebook cell here. And if I go into the diff of,

00:17:05.660 --> 00:17:10.340
if I go into the source control panel, after editing this Jupyter notebook cell, I can actually see a

00:17:10.340 --> 00:17:16.380
real, a real diff side-by-side with those, with those cells. So that's, that's something cool you can

00:17:16.380 --> 00:17:20.860
do without having to install a full editor and things locally.

00:17:20.860 --> 00:17:26.880
Very cool. Yeah. And it's a nice diff of the cell contents, not like the JSON crazy diff.

00:17:26.880 --> 00:17:33.760
Yeah. You get the left, red, right, left, right with red, green, add, remove. Yeah. And outputs are

00:17:33.760 --> 00:17:38.720
squashed. So you're not seeing a bunch of, if you diff a notebook, you'll see a bunch of XML and JSON

00:17:38.720 --> 00:17:42.120
being removed and added. This is, this is more of that rich.

00:17:42.960 --> 00:17:49.260
Take all of the various encoding language storage formats and then jam them all together and then

00:17:49.260 --> 00:17:51.900
diff that. That's fun. Yeah. No, this is awesome. This is a great view.

00:17:51.900 --> 00:17:53.620
Click it. I'm going to use it.

00:17:53.620 --> 00:17:54.300
Indeed.

00:17:54.300 --> 00:18:00.840
So one of the things that I don't really edit on and get very much, what happens like once you're

00:18:00.840 --> 00:18:03.960
done, does it create a merge request or just edit it in place or?

00:18:03.960 --> 00:18:10.240
It makes a commit directly to the repository. So I can just throw that right in there.

00:18:10.740 --> 00:18:15.000
And so you have to have, you obviously have to have permissions. You have to be one of the people

00:18:15.000 --> 00:18:20.580
that can commit directly to that branch. Right. Yeah. Yeah. This is great. I was so delighted when

00:18:20.580 --> 00:18:25.400
I saw it. So I'm going to definitely use this. Nice. All right, Brian, am I up on the next one?

00:18:25.400 --> 00:18:26.400
You are.

00:18:26.400 --> 00:18:32.400
All right on. Let's move on to it. Okay. I'm resisting the temptation to hit dot and play around with the

00:18:32.400 --> 00:18:38.300
wake pie. Instead, let me take you over here. So we go to Python. That's, that's not Python bytes.

00:18:38.300 --> 00:18:43.980
Close, but not exactly. Gosh. And they don't even, why did I type com? I've never, hold on.

00:18:43.980 --> 00:18:49.200
Python bytes.fm. That's our domain. So we're live streaming right now, by the way, if you didn't

00:18:49.200 --> 00:18:55.660
notice. If you go over here, notice I've got Firefox that I'm using and it has this little shield and

00:18:55.660 --> 00:19:01.020
almost anything you go to, man, I want to go to a new site, but let's go to CNN and you'll come over

00:19:01.020 --> 00:19:07.400
here and you'll see a bunch of stuff up here getting blocked, like social media trackers,

00:19:07.400 --> 00:19:13.200
tracking content. Like, look at that. That's a ridiculous amount of gross Google analytics,

00:19:13.200 --> 00:19:20.060
Google tag services, Rubicon project, US East, apparently like that's bad. Right. So I've done

00:19:20.060 --> 00:19:25.760
a lot of work. Get us away from retargeting tracking. And we have no known trackers.

00:19:25.920 --> 00:19:30.400
And I'm running a VPN, which probably blocked a bunch of the ones off of CNN. So that was the

00:19:30.400 --> 00:19:37.680
ones that got through the blocking and stuff. So it's really nice to not have all that stuff and

00:19:37.680 --> 00:19:41.640
let people come visit the site and know that we're not retargeting them. We're not tracking them. We're

00:19:41.640 --> 00:19:47.040
not doing stuff. We're just giving them a podcast or same thing over on talk by then training or talk

00:19:47.040 --> 00:19:53.300
Python or whatever. Right. You go there, you get the content. We offer things like a podcast with ads

00:19:53.300 --> 00:19:57.800
that people can take. And that's enough. We don't need to like follow you around for all sorts of

00:19:57.800 --> 00:20:04.040
creepy reasons. Right. The drawback is we don't have a lot of analytics. Right. We can get a sense

00:20:04.040 --> 00:20:09.240
about like download numbers and things like that, but we can't report like, well, in the last hour,

00:20:09.240 --> 00:20:16.480
since we talked about this thing, here's the traffic. Can we, or would we? So, junction apps

00:20:16.480 --> 00:20:22.360
over on Twitter said, Hey, you know what? I heard you going on and on about, the retargeting of all

00:20:22.360 --> 00:20:27.460
these places and how you dropped it. Have you heard about go access.io? Have either of you heard

00:20:27.460 --> 00:20:34.160
about this thing? No, no, I hadn't either, but check it out is super cool. So what it is it is a

00:20:34.160 --> 00:20:41.540
Google analytics like service that you install on your server. And what it does, if I put this image

00:20:41.540 --> 00:20:47.860
in a tab, so it doesn't go away. What it does is it looks and tails your logs and gives you real-time

00:20:47.860 --> 00:20:54.160
analytics on your logs rather than by looking at, going through JavaScript and hooking into

00:20:54.160 --> 00:20:59.060
people's browsers. So no tracking, none of that stuff, but you can come over here and in your

00:20:59.060 --> 00:21:05.540
terminal, run it and get a real-time view of your traffic, your visitors, all the kind of stuff you

00:21:05.540 --> 00:21:11.000
would expect from Google analytics visually as a graph-like thing in your terminal. Interesting,

00:21:11.000 --> 00:21:12.100
huh? It's really cool.

00:21:12.200 --> 00:21:13.920
Yes. What kind of information are you getting?

00:21:13.920 --> 00:21:18.240
Well, probably the easiest way to find out is they have a web view and have the terminal view

00:21:18.240 --> 00:21:23.900
and the web view is really generate a HTML file and then just request it. So there's not like a web

00:21:23.900 --> 00:21:28.080
server type thing, but you go over here and click, it says here, I'll give the, give you the features

00:21:28.080 --> 00:21:33.300
real quick. Then open up the demo. It says fast real-time millisecond, based, you know,

00:21:33.300 --> 00:21:38.960
latency updates written in C only uses in cursors of the dependencies works on almost all the formats

00:21:38.960 --> 00:21:44.860
engine X amongst the others. just set the log format and run it on your log, got the terminal and

00:21:44.860 --> 00:21:50.360
the UI, the web UI bit. So if you go over here, you can see like, look at this off of just the log

00:21:50.360 --> 00:21:55.520
files. So you can see things like here, I'll pull them up. So you can go over and say, well, what are the

00:21:55.520 --> 00:22:01.760
referring URLs? let me make that small. So you can kind of see in here, unfortunately,

00:22:01.760 --> 00:22:06.760
here's the referring URLs. So you can see in this example, they were, you know, shop internet,

00:22:06.760 --> 00:22:10.960
whatever, right? At least it'll, it's a fake site, but you can come over here and like actually see

00:22:10.960 --> 00:22:18.220
graphs as well as like grids and pages. So like think Google analytics, but if you run a site and you

00:22:18.220 --> 00:22:24.060
can point this against your logs and get real time information in the terminal or as in this web view.

00:22:24.180 --> 00:22:28.600
And yeah, it's, it's pretty neat. And so do you, you don't, do you have to install anything or do

00:22:28.600 --> 00:22:32.560
you just run this and it finds the logs on your system and pulls it all together?

00:22:32.560 --> 00:22:39.780
Yeah, you do have to install. Let's see here. so there's a getting started and it says the way to

00:22:39.780 --> 00:22:44.380
get started probably to use a package manager for your Linux machine. If you're running on Linux,

00:22:44.380 --> 00:22:49.700
or you can get a Docker image and you run it. And then the, what you do is you just simply run the

00:22:49.700 --> 00:22:56.280
command against your log file and, and tell it what format and boom, off it goes. So you could

00:22:56.280 --> 00:23:01.500
set it up as a, like a cron job or something that will then generate the HTML file. And you could just

00:23:01.500 --> 00:23:05.520
refresh that, you know, however often you want to, or run the terminal one.

00:23:05.520 --> 00:23:07.760
You could run it once a day too.

00:23:07.760 --> 00:23:10.460
And yeah, you don't need, save the report.

00:23:10.580 --> 00:23:16.020
Exactly. Yeah. You don't need real time, real time. You need just sort of how's the day going

00:23:16.020 --> 00:23:17.560
or something like that. How was yesterday?

00:23:17.560 --> 00:23:22.420
Right. So like one of the things that I use information like this about is I don't really

00:23:22.420 --> 00:23:26.320
want to track users. I don't care about individual users, but I do want to know,

00:23:26.320 --> 00:23:33.140
like I've got putting out different content on my blog or on a podcast, which ones, which,

00:23:33.140 --> 00:23:38.760
which ones are resonating with people and maybe do more of that. yep. So,

00:23:38.760 --> 00:23:45.500
so you can see like, there's a little bunch of options here for insights, hosts, requested

00:23:45.500 --> 00:23:51.000
files, they call it, but it's really just URLs. so you go over here and this would tell

00:23:51.000 --> 00:23:56.360
you sort of the traffic, you know, across your various, pages, right? So this would be

00:23:56.360 --> 00:24:01.020
like your list, this, requested files, URLs are the one you'd want. Yeah. Yeah. So anyway,

00:24:01.020 --> 00:24:04.960
I haven't set this up yet, but it looks pretty neat and it could be worth checking out.

00:24:04.960 --> 00:24:08.500
Yeah. Neat. And I guess even you could download your logs.

00:24:08.500 --> 00:24:12.040
And not install it on your server. If you really wanted, right? You want this view,

00:24:12.040 --> 00:24:16.400
but you don't actually want to put it on your server because putting stuff on the server.

00:24:16.400 --> 00:24:20.440
Well, you know, so you could download it and then just run against your logs locally.

00:24:20.440 --> 00:24:25.460
And you might be uploading your logs to a storage account somewhere too, on a cron job.

00:24:25.460 --> 00:24:29.240
Yeah, exactly. You could push the logs out instead of, running it there. So

00:24:29.240 --> 00:24:33.060
a bunch of cool ways to use this, but if people are running web apps and they want more visibility

00:24:33.060 --> 00:24:37.500
into it, this, this looks like a cool thing. So thanks, junction for sending that over.

00:24:37.500 --> 00:24:38.680
All right. Off to you, Brian.

00:24:38.680 --> 00:24:45.760
I want to talk about keyboards a little bit. So this was a topic and talk a topic recommended by

00:24:45.760 --> 00:24:55.160
somebody named blaze blaze, I think. so there's a, a package called KMK. It's actually a collection of,

00:24:55.160 --> 00:25:00.920
uh, collection of pieces of software, but it's, the, we're linking to the KMK firmware.

00:25:00.920 --> 00:25:07.040
So this is firmware for computer keyboards written and configured in circuit Python.

00:25:07.040 --> 00:25:12.400
So got super excited about this. I'm still kind of excited about it. the gist of it is,

00:25:12.400 --> 00:25:21.000
is, you've got, if there's, if you've got a keyboard that, that runs a, run circuit Python

00:25:21.000 --> 00:25:27.680
and it's powerful enough to, to run, to handle your keyboard and stuff. So there's,

00:25:27.680 --> 00:25:32.600
there's a couple of tips in here. There's a couple available through Adafruit, of different,

00:25:32.600 --> 00:25:38.820
um, different boards that would work. We'll get into the details a little bit more, but, I,

00:25:38.820 --> 00:25:45.540
basically you can configure a keyboard with a single file, single Python file. You can, it controls

00:25:45.540 --> 00:25:51.720
both, split keyboards, two pieces, keyboards, and single keyboards. You can, hook up macros,

00:25:51.720 --> 00:25:57.540
things like, chainable macros, to, so you can, have key sequences built into one,

00:25:57.540 --> 00:26:04.220
one key, or you can hook it up so that a key hitting multiple times, you can hit like a particular key

00:26:04.220 --> 00:26:09.960
three times in a row and you'll have one action versus something else. So, even controlling

00:26:09.960 --> 00:26:15.780
under glow and LEDs and backlights and all that sort of stuff totally would be fun. I want to use this.

00:26:15.780 --> 00:26:22.940
I don't know how it seems like a lot of work though. So, so we're linking to the, the,

00:26:22.940 --> 00:26:28.120
the, the project and there's some information here. There's some guides on how to get started.

00:26:28.300 --> 00:26:34.340
And then we're also going to run, I found somebody that ran this, and, and the, he's

00:26:34.340 --> 00:26:41.320
got a video that walks through, doing it. But the gist of it is, is there aren't any keyboards

00:26:41.320 --> 00:26:46.720
that do this right away. So you've got to take an existing keyboard, rip out the existing circuit

00:26:46.720 --> 00:26:52.840
board and replace it with one of the 80 fruit board, 80 fruit boards, and then, and then reprogram

00:26:52.840 --> 00:26:58.560
it. So if you're the kind of person that's okay with ripping the circuit, circuit board out of

00:26:58.560 --> 00:27:02.740
your keyboard and replacing it with something else, that'd be great. And I actually wouldn't mind doing

00:27:02.740 --> 00:27:07.720
this. I think that'd be fun, but I'd kind of like to know which keyboards I can do this with and which

00:27:07.720 --> 00:27:11.380
ones I can't. I know there's a huge list of keyboards out there, but even just a couple

00:27:11.380 --> 00:27:14.000
like starter kits would be great to hear.

00:27:14.000 --> 00:27:20.060
It really works well with this one. And here's where the circuit Python board fits in there easily

00:27:20.060 --> 00:27:22.840
rather than, yeah, it doesn't really go back in.

00:27:22.840 --> 00:27:27.920
Yeah. So one of the reasons why I'm bringing this up is I'd love somebody from Adafruit or from,

00:27:27.920 --> 00:27:34.600
work, anybody working on circuit Python or the came came K team or somebody to, maybe put a couple more

00:27:34.600 --> 00:27:41.100
tutorials out to just say, Hey, this is how you do it for like, I'd love it to have like an off the

00:27:41.100 --> 00:27:46.180
shelf full keyboard, even if it's small or whatever that it said, okay, here's, here's,

00:27:46.180 --> 00:27:52.200
here's how you do it. You pull this circuit board out, put this other one in, it's like $40 on Adafruit.

00:27:52.200 --> 00:27:59.360
And there you go. You can, you can try it. And here's a sample of file that you would run it,

00:27:59.360 --> 00:28:07.360
run just a normal keyboard, usage. And now, now you can customize it because the, just getting back

00:28:07.360 --> 00:28:12.440
to a workable keyboard seems already like a lot of work, but it still looks fun. I'd love to be able

00:28:12.440 --> 00:28:19.360
to hack a keyboard with Python. Very cool. Dan, what kind of keyboard do you use? well, I use,

00:28:19.360 --> 00:28:25.680
I'm a big fan of the thin keys, right? The very, the very light travel keys, but I got the ergonomic

00:28:25.680 --> 00:28:32.700
keyboard. so thin ergonomic Logitech, not into the, I've got the, I've got the, Microsoft

00:28:32.700 --> 00:28:38.980
sculpt ergonomic, which I absolutely love. I know Brian's got even more exotic stuff that he's

00:28:38.980 --> 00:28:42.120
running over there. I don't know if I can get mine up here. I'll, I'll, I'll do the camera.

00:28:42.120 --> 00:28:47.080
It's like, it's mounted to the, no. Oh, my junk too. I've got a Kinesis.

00:28:47.080 --> 00:28:53.220
Yeah. The Kinesis inverted ones. Those are super interesting. What I would like to see would be

00:28:53.220 --> 00:28:58.200
some keyboard manufacturer saying we're shipping a keyboard to you. Oh, and you can program it with

00:28:58.200 --> 00:29:03.820
Python and basically do this for you as a package thing and just, you know, build it out of these

00:29:03.820 --> 00:29:08.480
components. That'd be fantastic. Yeah. That'd be great. Well, I think it'd be fun with, with everyone

00:29:08.480 --> 00:29:13.880
decking out their home offices these days. If you could do a little bit of magic light show while

00:29:13.880 --> 00:29:19.060
you're presenting or talking on a call, that would be really cool. That'd be fantastic. Yeah. Hey,

00:29:19.060 --> 00:29:23.760
Brett Cannon's out there in the live stream. Danny may have heard of this guy, Pablo,

00:29:23.860 --> 00:29:32.300
Pablo, Delgado has programmed his keyboard RGB lights to color code the build bot status for

00:29:32.300 --> 00:29:36.980
CPython. I don't know which library uses. That's awesome. So like it's green if everything's good,

00:29:36.980 --> 00:29:40.960
but it turns red if CI fails or something like that. Oh, that's awesome, Brett. Thanks for sharing.

00:29:40.960 --> 00:29:46.000
That'd be cool. You know, I never really, I mean, when I first saw the LEDs under the keyboards,

00:29:46.140 --> 00:29:51.280
I thought, you know, yeah, gamers like it, but I don't think I would probably have a use for it,

00:29:51.280 --> 00:29:55.920
but now I'm jealous. I want, I want, I want to light up things on my keyboard. It'd be fun.

00:29:55.920 --> 00:30:00.480
Yeah. Especially if you could program them, right? Like this, this example here, my mouse

00:30:00.480 --> 00:30:06.060
sits here and pulsates and changes color, but because it's on a Mac, the software doesn't work

00:30:06.060 --> 00:30:09.860
and I can't do anything with it. So it's, it just annoys me there. It's a good mouse otherwise,

00:30:10.080 --> 00:30:16.480
but anyway. So is it a windows only thing or what? No, the mouse is perfect on Mac,

00:30:16.480 --> 00:30:21.000
but the software that lets you customize it and do interesting things to the colors doesn't work

00:30:21.000 --> 00:30:28.720
on the Mac. Lame. Super lame. Super lame. All right. What is not lame is this last thing that Dan has

00:30:28.720 --> 00:30:33.000
got here. Cause this thing has been blowing up on Twitter. It's all of a day old with like 2000

00:30:33.000 --> 00:30:37.000
GitHub stars. And I was like, Oh, this has got to be covered. And then Dan, you were on it.

00:30:37.000 --> 00:30:40.060
Yeah. I just saw it yesterday and I was like, I have to talk about this.

00:30:40.880 --> 00:30:46.140
So I know that when I've built web apps in the past, one of the big frustrations I have is

00:30:46.140 --> 00:30:51.700
that when you want to add something new to your database, you need to add it to the SQL queries.

00:30:51.700 --> 00:30:57.360
You need to add something to the backend code. You need to add a piece to the API that, that then

00:30:57.360 --> 00:31:02.620
returns that, that new object to users. And then in your client code, you need to consume it. And so

00:31:02.620 --> 00:31:07.300
there's all this repetition that you're doing across your web app every time you need to

00:31:07.300 --> 00:31:12.540
make a change to your data or add a new object. And that's very error prone as well.

00:31:13.380 --> 00:31:20.800
And so things like SQL, SQL, SQLAlchemy, you can use to write code that interacts with your

00:31:20.800 --> 00:31:28.660
database. And then things like FastAPI, you can use Pydantic to return models to your users,

00:31:28.660 --> 00:31:35.600
to the, to your APIs. But then that now, now we had this thing where, where you have SQLAlchemy

00:31:35.600 --> 00:31:39.800
models and Pydantic models, where, and then you're translating back and forth between them.

00:31:39.800 --> 00:31:48.760
And so, Sebastian Ramirez, who just, just released yesterday, this new SQL model library, which looks

00:31:48.760 --> 00:31:55.320
just awesome because it actually combines the schema for talking to the database and speaking to your API

00:31:55.320 --> 00:32:03.960
into one, one schema object that you write. So, what's really cool about this is that, so the way you work

00:32:03.960 --> 00:32:10.440
with this is that you define your objects. For example, he's got in the GitHub repo, this hero class

00:32:10.440 --> 00:32:17.720
with an ID name, secret name, age. And it's, it's got some of the SQLAlchemy type things like it's your

00:32:17.720 --> 00:32:24.120
primary key is the ID is optional, but it's defaults to not its primary key. So what's really cool about it,

00:32:24.120 --> 00:32:30.600
this class is both a SQLAlchemy model and a Pydantic model. I don't know how he did that. He said there's

00:32:30.600 --> 00:32:36.280
some magic that's going on behind the scenes. And so what's really cool is that you can use this to

00:32:36.280 --> 00:32:43.240
instantiate your database. So you can, you can, so you've got this hero class, you can create objects in

00:32:43.240 --> 00:32:49.720
the database by going hero one, hero two, hero three equals hero bracket and pass the name, secret name,

00:32:49.720 --> 00:32:57.720
all the fields to the object. And, you can also return those same objects. You can use that same hero

00:32:57.720 --> 00:33:06.200
class and use it in your FastAPI. So you can, accept hero objects. you can, return hero objects. And so that's,

00:33:06.200 --> 00:33:13.240
that's one, you write that one schema and you, and you use it in multiple places. Yeah. What you have on the screen here for a FastAPI is

00:33:13.240 --> 00:33:20.360
response model equals the database entity, which that then drives the open API documentation

00:33:20.360 --> 00:33:25.720
in addition to just driving. Yeah, exactly. You got it right there. So you can go there and

00:33:25.720 --> 00:33:30.520
it's sort of end to end the same model, which I think is really great. Yeah. And so you can look at your

00:33:30.520 --> 00:33:38.680
in, with FastAPI, if you go to slash docs, you get the swagger, UI. And so you can see that same

00:33:38.680 --> 00:33:44.280
schema with the ID name, secret name age. And, what's really cool about that is that it also has,

00:33:44.280 --> 00:33:50.840
this generates the open API.json. And so you can use tools like open API generator to even generate

00:33:50.840 --> 00:33:57.640
client code and all the, any different language that you're using like Python, JavaScript, Lua. And,

00:33:57.640 --> 00:34:03.640
so, so you can, if you just went back to that original hero class and added a new field, you could

00:34:03.640 --> 00:34:09.160
potentially have it in all different layers of your application, with one, including the consuming

00:34:09.160 --> 00:34:14.520
clients. Cause they could regen off of the JSON schema. Yeah. Yeah. So I think that's really cool.

00:34:14.520 --> 00:34:20.200
And, and one other really nice thing that, that Sebastian did here is that he really emphasized

00:34:20.200 --> 00:34:25.960
making sure that in the editors that you have a good experience with autocomplete because,

00:34:26.840 --> 00:34:32.760
in the past stuff like the Django ORM and the SQLAlchemy ORM, the editors have had to write

00:34:32.760 --> 00:34:39.240
custom code to be able to have a good autocomplete experience for that. and so Sebastian used,

00:34:39.240 --> 00:34:45.400
type hints, really well throughout the design of this so that as you're, returning objects from

00:34:45.400 --> 00:34:51.080
the database, you actually get, you can, once you return that object from the database, you actually get,

00:34:51.080 --> 00:34:54.440
um, autocomplete on it. I can show that here.

00:34:54.440 --> 00:35:00.280
Yeah. That's really cool because a lot of times you just get star, star KWR, you know, like, oh, thanks.

00:35:00.280 --> 00:35:07.320
Yeah. So I got this statement, select hero, where hero name equals hero name, and then the object

00:35:07.320 --> 00:35:11.480
that returns, I can go hero dot, and then, sorry, that was working.

00:35:11.480 --> 00:35:13.320
Put it at the very end of the line, maybe. Yeah.

00:35:13.320 --> 00:35:19.240
Or in the next line. Yeah. Yeah. yeah, I can, so I can access all the properties on,

00:35:19.240 --> 00:35:24.280
on the hero object. one, one cool thing about, how he did this. He used

00:35:24.280 --> 00:35:31.320
a, a proposal from, Eric Traut, the author of Pyright called the data class transform

00:35:31.320 --> 00:35:38.760
that, it's this proposal that basically you can annotate various objects to say that they behave

00:35:38.760 --> 00:35:44.120
like data classes. And so that that's kind of the magic that allows some of this dynamic behavior to

00:35:44.120 --> 00:35:45.720
show up in, in type checkers.

00:35:45.720 --> 00:35:50.360
I love it because so often you'll do a SQLAlchemy query or something and what you get back, it's

00:35:50.360 --> 00:35:52.840
so many layers. It's lost what that type is.

00:35:52.840 --> 00:35:53.240
Yeah.

00:35:53.240 --> 00:35:55.800
It's like, ah, now I got to like re-annotate it again.

00:35:55.800 --> 00:35:59.800
I got to search for everything. Look at all the different source code in my code base and stuff

00:35:59.800 --> 00:36:01.640
like that. So this is really cool.

00:36:01.640 --> 00:36:09.080
We've got some great comments in the chat. here's, here's one. I swear Sebastian spends as

00:36:09.080 --> 00:36:14.520
much time on his docs as he does his code. Amazing talent. I got it. And we were talking about

00:36:14.520 --> 00:36:20.600
type hints and the editor experience as well. Sebastian does a great job with the onboarding

00:36:20.600 --> 00:36:26.280
experience as well as the, youth, the developer experience. And a lot of large companies could pay

00:36:26.280 --> 00:36:31.400
attention to what this one person is doing, making it easy for people to pick up a new tool. It's amazing.

00:36:31.400 --> 00:36:36.040
Yeah. I mean, look at the docs here. These are, this looks like a professional team wrote all this

00:36:36.040 --> 00:36:42.120
stuff, right? This is, this is incredible. Instead of one, a very productive guy.

00:36:42.120 --> 00:36:47.080
And then, Brett, good question. I want to know how Sebastian manages to release a new,

00:36:47.080 --> 00:36:53.640
very cool project every single year. No kidding, man. He has a powerhouse. He's like changing how we

00:36:53.640 --> 00:36:59.960
do web development. and, and it's just one person. But yeah, you know, I think I can,

00:36:59.960 --> 00:37:05.720
speak to that just a little bit, by the way, if you look at the magic of FastAPI, you look at

00:37:05.720 --> 00:37:11.240
what's happening here. These are really nice things to work with, but they're not from the ground

00:37:11.240 --> 00:37:18.520
recreations of what they are. This takes Pydantic plus SQLAlchemy and makes it better. FastAPI

00:37:18.520 --> 00:37:23.800
takes Starlette and Pydantic and makes them better, right? It's like the recombining of things that are

00:37:23.800 --> 00:37:29.240
already really good into something better. Yeah. And some cool things that, that come as a result of

00:37:29.240 --> 00:37:34.760
that repackaging. So according to Sebastian, this should support async database sessions out of the

00:37:34.760 --> 00:37:40.120
box, because that's something that SQLAlchemy supports, Alembic migrations as well.

00:37:40.120 --> 00:37:46.120
and in theory it should be possible to integrate with post gists and TS vectors, for doing

00:37:46.120 --> 00:37:51.960
geo stuff and full text search with, with, with Postgres, but he says he hasn't tested it yet.

00:37:51.960 --> 00:37:57.080
Yeah. I have no idea, but potentially async and await as well. Now that SQLAlchemy supports that.

00:37:57.080 --> 00:37:57.480
Yep.

00:37:57.480 --> 00:38:01.560
But again, this is a day old, so we haven't really had a chance to dig in it too much. I want to highlight

00:38:01.560 --> 00:38:05.880
just a couple more comments. Savannah on the live stream says, Sebastian's attention to developer

00:38:05.880 --> 00:38:11.960
experience is so awesome. Yeah, I agree. Keep it up, Sebastian. And Rehan says, it looks great for a

00:38:11.960 --> 00:38:16.840
toy case, but people make professional interior systems. do they really want to share the same

00:38:16.840 --> 00:38:22.520
types between their database and their rest API? That's a good question. I was thinking about

00:38:22.520 --> 00:38:26.520
that as well. One of the challenges that you can run into when you just sort of say, oh, here's my

00:38:26.520 --> 00:38:31.480
data model out onto the internet as JSON. And then take, especially taking it back as you can run into

00:38:31.480 --> 00:38:38.840
like situations where you overexpose information or you run and run into a mass assignment type of bugs

00:38:38.840 --> 00:38:44.680
where values get set or you didn't expect them to be set. So with Pydantic, you can do things like

00:38:44.680 --> 00:38:49.720
call, you have to call to JSON, but you can also, or to dict, I can't remember. I think the dict,

00:38:49.720 --> 00:38:55.240
but you explicitly opt in or opt out certain fields. So you could do things like that about

00:38:55.240 --> 00:39:01.560
bringing those in. so pretty neat, but yeah, you gotta be a little bit careful about that.

00:39:01.560 --> 00:39:06.200
but yeah, very cool stuff. You don't want your password hashes on your user object.

00:39:06.200 --> 00:39:09.720
Exactly. If you're going to return your user, you don't necessarily want to exactly return,

00:39:09.720 --> 00:39:13.560
say the password hash or God forbid, not just the straight password.

00:39:14.360 --> 00:39:18.360
If you're not hashing it, but that's a bigger problem, but still.

00:39:18.360 --> 00:39:24.680
Oh, I wanted to bring up one more thing is, his, his choice of heroes in his example.

00:39:24.680 --> 00:39:31.720
Love these. we've got dead pond, spider boy, and rusty man. hilarious.

00:39:31.720 --> 00:39:33.560
Love it. Yeah. Those are great.

00:39:33.560 --> 00:39:40.520
Well, so those are our six items. do we have, any extras? Do you got anything to share?

00:39:40.520 --> 00:39:45.240
Right. sometimes I have extra, extra nine times here all about it. I got none this time. How about you?

00:39:45.240 --> 00:39:47.560
really? I've got like two.

00:39:47.560 --> 00:39:49.560
So I bring one.

00:39:49.560 --> 00:40:07.560
so, first one I wanted to bring up was, really fun episode. people know I also do a podcast called testing code episode 163. does, it's a talk with, Stefan Bedul about, pip install of local directory.

00:40:07.560 --> 00:40:32.440
And, so if you're, if you're doing anything where you, do the pip install of a local directory, definitely check that out. Or especially if you never knew that you could do that. it's a good episode. the other thing I wanted to bring up, is, it's been like five episodes since I plugged my book, but no, I, there's a chapter 12 is up.

00:40:32.440 --> 00:40:43.400
So chapter 12, the first, one of the things I got, questions about for the first edition was it's the whole book is talking about testing packages and there's a lot more in the Python world than just packages.

00:40:43.400 --> 00:40:57.380
So chapter 12 is a reaction to that. It's testing scripts and applications. So it's not a pivot. If you don't have a pip installable package, you can still use pytest to test it. And chapter 12 directly addresses that. So I wanted to bring that up.

00:40:57.380 --> 00:41:01.600
Awesome. Alvaro out in the live stream says, how is the second edition testing mode going?

00:41:01.700 --> 00:41:05.340
Yeah. It looks like chapter 12 is coming along. Well done. You're basically done, Brian.

00:41:05.340 --> 00:41:06.840
You're on vacation.

00:41:06.840 --> 00:41:18.160
Well, there were less than 10 chapters in the first book, but now I'm, I'm working on chapter 13, planning on 17 altogether. it's going to come out in hard copy early next year.

00:41:18.160 --> 00:41:19.280
So super.

00:41:19.280 --> 00:41:20.620
I have one extra.

00:41:20.620 --> 00:41:21.040
How about you, Dan?

00:41:21.040 --> 00:41:31.560
Yep. So one, one cool library that I wanted to share is a type for pie. So we've been talking about types a lot lately. Seems like it's a, it's a regular topic of conversation.

00:41:31.560 --> 00:41:48.200
And, they, they can provide a lot of benefits to your code base and to text editors, like VS Code or, or PyCharm. And, but what happens if you want to retrofit or add a bunch of types to a code base that's not typed already? That's, that's a big daunting task.

00:41:48.200 --> 00:42:01.740
And so I came across this library, you know, shared amongst our team. And what I thought was really cool about it is that, it's a state of the art machine learning model for inferring types.

00:42:02.200 --> 00:42:09.360
So we've, we've talked about before, Hey, wouldn't it be cool if we could just go generate all the types for all the packages out there so that we could have great autocomplete on everything.

00:42:09.360 --> 00:42:14.560
But it turns out you can't because you can't do that until you actually run the code and have the objects to bind it to.

00:42:14.660 --> 00:42:24.640
And so, this machine learning model is sort of the latest in a line of, of attempts, from different researchers to create a good machine learning model for inferring types.

00:42:24.640 --> 00:42:35.800
what, what I like about it is not only is it, it sort of best in class in terms of its, accuracy is that the author of this machine learning model,

00:42:35.800 --> 00:42:43.660
open-sourced the training data set with, with 4.3 million type annotations in it, the training code.

00:42:43.660 --> 00:42:55.820
So you can go in and actually, use, train this on your own code, following some of these very simple commands to, to train the model and pre-processed, process the data with your own code base, open source to a VS Code extension.

00:42:55.820 --> 00:42:57.640
So you can actually have developers using it.

00:42:57.640 --> 00:43:00.240
It's not just some, Hey, this is our results.

00:43:00.240 --> 00:43:01.640
QAD, go read the paper.

00:43:01.640 --> 00:43:03.540
It's, it's actually something that you can use.

00:43:04.000 --> 00:43:11.660
and so if you're looking at trying to retrofit a bunch of types into your code base, this is something you might want to try out.

00:43:11.660 --> 00:43:20.600
just one sort of quick caveat that, that the sample VS Code extension uses the machine learning model that's hosted on type4py.com.

00:43:20.600 --> 00:43:31.600
And so if, if you're not working on an open source project, you, you probably want to, fork the extension and, stand up the machine learning model, using the web server that, that he links to.

00:43:31.600 --> 00:43:33.340
Yeah, that's a good bit of warning.

00:43:33.420 --> 00:43:34.320
But this looks super cool.

00:43:34.320 --> 00:43:41.520
it seems like one of those things you could do a first pass, retrofit it, and then go back and check it out, run mypy against it.

00:43:41.520 --> 00:43:48.660
you could even go to Pydantic and use the validate decorator and put that on all the things and make it, then run your tests.

00:43:48.660 --> 00:43:52.740
The validate actually verifies the type annotations really match the runtime behavior.

00:43:53.200 --> 00:43:55.320
so yeah, a lot, a lot of neat things.

00:43:55.320 --> 00:43:55.900
Excellent.

00:43:55.900 --> 00:43:57.740
Brian, did you think that was funny?

00:43:57.740 --> 00:44:00.540
No, no, not funny at all.

00:44:00.540 --> 00:44:02.020
This might be funny.

00:44:02.020 --> 00:44:03.440
We, we need something funny.

00:44:03.440 --> 00:44:04.020
Yeah.

00:44:04.020 --> 00:44:08.380
So we've been doing a lot of geek and poke lately and, yeah, this is a really good one.

00:44:08.380 --> 00:44:13.240
So, you know, we talk about testing and we talk about continuous integration.

00:44:13.240 --> 00:44:19.920
If you want to take that, like you go from testing to CI to the next level, we're talking continuous delivery, right?

00:44:19.920 --> 00:44:21.660
I'm going to git pushed to the production branch.

00:44:21.660 --> 00:44:24.440
That's going to kick off the CI, which is going to kick off a deployment.

00:44:24.440 --> 00:44:25.660
Glorious, right?

00:44:25.660 --> 00:44:26.240
Yeah.

00:44:26.600 --> 00:44:28.180
Well, we've got a cartoon around it.

00:44:28.180 --> 00:44:34.100
So there's this, man, a woman developer pair, and they're just looking like perplexed at each other.

00:44:34.100 --> 00:44:42.360
It says for five days, I've been doing nothing else than trying to deploy this blinking application on our production environment.

00:44:42.360 --> 00:44:44.400
Title continuous deployment.

00:44:44.400 --> 00:44:49.340
That's one way to interpret that.

00:44:49.340 --> 00:44:49.680
Literal.

00:44:49.680 --> 00:44:51.540
Very literal.

00:44:51.540 --> 00:44:52.880
Yeah.

00:44:52.880 --> 00:44:53.520
All right.

00:44:53.520 --> 00:44:55.140
Well, hopefully that was more funny.

00:44:55.140 --> 00:44:55.840
Yeah.

00:44:56.060 --> 00:45:00.340
So I've got a not very good joke, but I thought it was funny anyway.

00:45:00.340 --> 00:45:02.920
it was, shared to us.

00:45:02.920 --> 00:45:06.360
it was first from, Carla, not a robot.

00:45:06.360 --> 00:45:11.700
It's a great handle and, told to us by blue fiddle guy also.

00:45:11.700 --> 00:45:21.240
So, joke is if a programmer gets an interview because of a recommendation from a friend, are they being passed by reference instead of value?

00:45:21.240 --> 00:45:22.300
I love it.

00:45:22.300 --> 00:45:24.960
Definitely passed by reference.

00:45:25.400 --> 00:45:25.640
Definitely.

00:45:25.640 --> 00:45:27.180
Well, this has been fun.

00:45:27.180 --> 00:45:28.360
So thanks everybody.

00:45:28.360 --> 00:45:29.480
Thanks Dan for showing up.

00:45:29.480 --> 00:45:30.260
Thank you for having me.

00:45:30.260 --> 00:45:30.740
Yeah.

00:45:30.740 --> 00:45:31.280
Thanks Brian.

00:45:31.280 --> 00:45:31.860
Thanks guys.

00:45:31.860 --> 00:45:32.620
Thanks everyone out there.

00:45:32.620 --> 00:45:33.240
Bye.

00:45:33.240 --> 00:45:33.980
Bye.

00:45:34.220 --> 00:45:35.920
Thanks for listening to Python bytes.

00:45:35.960 --> 00:45:36.960
Follow the show.

00:45:36.960 --> 00:45:38.680
Follow the show on Twitter via at Python bytes.

00:45:39.080 --> 00:45:40.080
That's Python bytes.

00:45:40.080 --> 00:45:41.900
That's Python bytes as in B Y T E S.

00:45:41.900 --> 00:45:44.340
Get the full show notes over at Python bytes.

00:45:44.340 --> 00:45:48.160
If you have a news item we should cover, just visit by the bytes.

00:45:48.160 --> 00:45:50.200
And click submit in the nav bar.

00:45:50.200 --> 00:45:52.320
We're always on the lookout for sharing something cool.

00:45:52.320 --> 00:45:59.820
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.

00:45:59.820 --> 00:46:04.280
That's usually happening at noon Pacific on Wednesdays over at YouTube.

00:46:04.280 --> 00:46:07.700
On behalf of myself and Brian Okken, this is Michael Kennedy.

00:46:07.700 --> 00:46:11.420
Thank you for listening and sharing this podcast with your friends and colleagues.