Python Bytes - #248 while True: stand up, sit down
Episode Date: September 2, 2021Topics covered in this episode: Why I use attrs instead of pydantic mclfy * Textual and* boilerplate removal xdoctest Automate the standing desk with python Hypermodern Python Cookiecutter Extras J...oke See the full show notes for this episode on the website at pythonbytes.fm/248
Transcript
Discussion (0)
Hey there, thanks for listening.
Before we jump into this episode,
I just want to remind you that this episode
is brought to you by us over at TalkPython Training
and Brian through his PyTest book.
So if you want to get hands-on
and learn something with Python,
be sure to consider our courses over at TalkPython Training.
Visit them via pythonbytes.fm slash courses.
And if you're looking to do testing
and get better with PyTest,
check out Brian's book at pythonbytes.fm slash PyTest. Enjoy the episode.
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 248, recorded September 1st, 2021. Gasp, it's summer over.
I'm Michael Kennedy.
I'm Brian Akin.
I'm Paul Everett.
Yay, Paul Everett's here.
Yay.
Welcome, Paul.
Joy to be here.
Longtime listener, first-time caller.
Yeah, I think you made an appearance in the previous show in the live chat, but now you're...
Oh, yes, the live chat.
Or possibly I talked Python.
I can't remember.
It all blurs together.
I wasn't as prepared as this one.
No, now you're on the big stage.
So thank you for being here.
Tell people about the things that you've been up to or what you're doing or who you are before we jump into our first topic. my job. I always joke that they should be, I should be paying them, but don't tell them I said that. And, uh, I'm just embarrassed that, uh, here I am on Python bites and I didn't get a haircut in time. I know this is a podcast, but there's a video version and that's right. Looking at Brian
rocking the do, I feel like I should have been better prepared. Yeah. Brian and I have alternate,
um, philosophies, I guess I've got like the like the knight's neat hair and Brian's just embracing it.
And yeah, I would do that too, except for mine just looks like a giant poofy thing on top of my head.
It doesn't look cool.
So yeah, not so much.
Oh, I want to see that.
Yeah, it's amazingly bad.
Yeah, I've tried it.
It's not amazing.
All right, but you probably have something amazing to tell us about, huh, Brian?
Well, I do.
Actually, so this is an interesting article.
I want to talk about both Adder's and Pydantic because we've talked about both of them on the show.
And they're both great libraries, I think.
And so there's this article that I came across called Why I Use Adder's Instead of Pydantic.
And there's actually a lot more in here than just that.
So it was an interesting read.
Starts out right off the bat talking about basically one of the things that a lot of
people think about with adders is, don't we have data classes?
Do we need adders anymore?
And it starts out talking about not talking about Pydantic, but talking about data classes.
And that data classes really came about as a subset of the adders functionality.
So it's really pretty easy to go back to using adders.
If you're familiar with data classes, it should be easy.
And actually, there's a lot of reasons to use adders instead.
For one, they're just faster, which I didn't know that they were faster.
But there's some examples about a lot of the boilerplate stuff that goes into data classes that we don't really think about.
But adders is pretty, pretty tight.
Also, adders has more features and has some validation code that isn't around for data classes.
So that's interesting.
So then getting into talking about Pydantic.
So I think of Adders as kind of like data classes, but it does more.
So Adders, this author summarized, Adders is a library for generating the boring parts of writing
classes and like the hash the equals the not equals that kind of stuff right yeah and property
and also like throwing in some validation if you want so you can uh opt in so putting in some
validation you can set that up um there's and there's a lot of stuff that Adders does. I mean, it's a lot more than that. It's a
pretty full library also. But what you get with Pydantic is you get that with the classes that
Pydantic provides, but you also have the validation library and structuring and unstructuring and
conversion to and from, like from a different type, like say JSON, into a pedantic class.
And all these components really are, with adders, you can do all of that. You just,
you opt in instead of having to opt out of it. And it's kind of a really interesting take on that.
And I thought of it as kind of like, you know, I've got a great screwdriver,
I've got great knives, but I don't think of my Swiss Army knife as a great anything.
It's just that it has everything.
I don't think it was that harsh of a comparison,
but we also think about that with like Django and Flask,
where Flask is kind of build up your own framework,
and Django has a lot of built-ins already. And it isn't even that simple. There was an example of
some of the validation that is built into Pydantic that just seems wrong. Like the example was,
if you've got a list of a thousand integers, do you really want
Pydantic to go and you pass in a list of integers?
You want to make sure it's passing in a list, but do you want it to go through and make
sure absolutely all a thousand elements is an integer?
You might, in which case you're in luck because that's what it does.
But if you don't want it to do that because that's that's just too much time uh you're out of luck uh the other well you also got to remember the the origins of
pydantic were about accepting input from arbitrary things on the internet oh yeah and when your your
goal is like i'm accepting unstructured data from random endpoint on a random endpoint like you need a different level of integrity than i loaded this off of a json file and i know the app created it it's not going to
be broken right it's going to be self-consistent at least in the fact that like the data types are
probably still consistent so so it's probably a when to use which sort of thing as well yeah so
that's the that's the generated, yeah. Adders class
and the generated Pydantic class. Um, so it's, it's around validation. Uh, yeah, it is interesting.
Um, the other, the other aspect is, uh, making sure that, uh, that, uh, data is validated when
it's set, not just when it's created. And I think I got lost here, but correct me if I'm wrong, Paul, but I think it's that
Pydantic only validates on creation, whereas you can set adders to be validating on setting values
as well. But I could be wrong. I believe you're right. I went and looked up a ticket in Pydantic.
I didn't read the whole thing about it, but these are hard conversations.
There's no free lunch.
And this article I thought was a fair treatment about the topic.
Yeah, the conversion bit was a little interesting.
Like, for instance, date conversion.
So if you pass in date time to a pedantic model, pedantic already has date time conversions built in.
So it'll automatically convert it.
But if you are using like pendulum,
which is a sub,
the class is a subclass of daytime,
you're going to get a wrong conversion.
It's just going to do it wrong
because it'll assume it's a daytime
and not a pendulum object.
So that's interesting.
Yeah, anyway, definitely something to think about
of the build your own versus having it all in one.
But I definitely think there's places for both.
Like what Michael said,
especially with input validation on the web,
if you know what you're doing,
definitely I think maybe you could roll your own
or use all these adders and other tools. But if you're just, definitely, I think maybe you could roll your own or use all these
adders and other tools.
But if you're just sort of playing at it and you're just getting started, then why not
try PyTandic?
It's a great place for that.
Yeah.
The other thing is about the open API specification stuff with PyTandic, where if you just use
them and you just say, I'm using this, it'll like automatically generate the documentation,
which is a big bonus. Yeah. It's interesting with the release of sql model it's like you can kind
of feel like pydantic is its own little mini framework dispatcher thingy with hook points
that you can plug into and almost treat almost treat as its own little API surface for gluing things together.
Yeah.
Yeah.
It's the data exchange bit.
Pretty interesting.
Brandon Brainerd out in the live stream says, I think it comes down to using the right tool
for the right job, which is, yeah.
And how you opened it.
Right, Brian?
Yeah.
All right.
So we all work with the terminal every now and then, right?
Every day.
You might be working with the command prompt if you're on Windows,
but I strongly encourage you not to do that.
You should be switching over
to the new Microsoft Terminal
with like, oh, my Posh Shell,
and then you'll be in the Terminal world as well.
So Dunderdan on Twitter
sent us a recommendation,
which I want to cover,
called McFly,
which I love the name. So what is it? It is
a bit of Rust code that extension for your terminal, super easy to install, like you can
brew install it and other types of install it. And basically what it does is it lets you fly
through your shell history. Okay, so depending on the shell you use, you may use this a lot,
or you may use this a little, you can hit control R in your terminal and it brings up a reverse history search. So like if
you knew that you type something to do with get it, it had to do with this repo. You could hit
control R and like type parts of the repo name. And that would start to auto-complete those
commands. There's a couple of things that are kind of a bummer about that, though. One is maybe the biggest one is you only see one of those at a time, right? So if I go and
say, show me my history, I get a line. And then that is the closest most recent match to what I
type. Well, what I often might want is like, it's kind of like a git clone, but which one was it?
And I want to see which ones of those are
that like that UI is not fantastic.
So imagine if you could type, say, Git clone
and then hit control R,
and it gave you like a UI in the terminal
that you could scroll through and pick,
and then you could see what else to type a little bit more.
That's McFly.
So it's pretty awesome in that regard,
but it also uses a little bit of AI,
if you will, a little neural network and some context awareness to help filter and order that.
I guess probably sort is probably the biggest thing is it'll say, well, what, you know,
you're searching for this, but usually when you're in this folder, you're often using this,
this version of that command. But if you're in a different folder, you're doing a different version
of get. And so it'll try to filter
your history based on the context
of where you are. What do you all think?
I think it looks pretty cool.
I was luckily... I
don't know why anybody would use
the built-in Windows command prompt.
So even on Windows, I'm using
bash.
Oh, my PowerShell is pretty sweet in the new terminal.
Carry on.
Carry on.
Sorry, don't mean to derail it.
Anyway, searching history with the VI mode is pretty easy in Bash.
But I was glad to see that this isn't just for your command prompt or Posh or anything.
You can use this with ZShell and Phish and Bash too.
Yeah, it works in a lot of them.
And so I found it to be quite neat.
So let's see, I'll run through some of the features.
So you just, it rebinds control R, which is kind of nice.
But one of the things, it'll store your history
in a little local SQLite database.
So it can do more queries and more interesting stuff,
have richer information on it. But it also injects the commands that it sees into your regular shell history. So if you
stop using it, your shell history for, say, ZShell is still totally good. That's pretty nice.
I will say that I know you had Brett on recently, and so the rustification of Python bytes
appears to be complete at this point you
can't go anywhere without bumping into rust i know you keep bumping into it it's quite interesting
here and my other comment is that uh i'm i hate to say it but i think the three of us were we've
been around so long we were pair programming with moses and the idea that i really needed a small
neural network for my shell is,
that's a tough one.
Yeah.
It's interesting, right?
Yeah, it is.
I mean, I do think it adds quite a bit of interesting extensions for this stuff.
Like it's a really cool way to do, you know, I use, oh, my Z shell.
So if I wanted like SSH somewhere, I could type SSH and just start hitting up arrow.
And it's like a beautiful history map.
Like I never use control R because there's a better one i gotta make that jump
one of these yeah it's so it's so good uh but sometimes i don't remember exactly what it is
or there's like a lot of them and so with this one it'll give you that drop down list that fills
the whole screen so you can jump through them you can also delete you're like this one i did once
but i never want to actually don't even want it my history you can delete it from your
history which is kind of nice um and then also let's go through some of the other things so
yeah so in terms of prioritization you know that little uh neural says it takes into consideration
the directory where you ran the command what you typed before the command so if if you did a get branch and then a checkout,
I don't know, maybe that means something or I don't know, whatever. But like the series of
commands that preceded it influence what it suggests and how it orders it, how often you
run it, when you last ran it, what you've selected in it as it's dropped down. And also
it's exit status. So if you ran a command but the command failed like it won't
auto suggest that command again because that one's the broken one you know i mean things like that
there's a lot of cool stuff oh that's cool and then i got one for you brian down here so it's
easy to install this you'd like you know brew install or um where's the probably an app to get
install or something anyway if i go down here there's all sorts of ways to install it.
But here we are.
Vim key bindings, Brian.
Yes, okay.
So, okay.
So you have Vim key bindings,
which is by default, it uses Emacs.
It definitely reminded me of like just firing up Emacs,
but for the shell, which was kind of nice.
The other thing that I like about it, I haven't turned this on yet, is fuzzy searching.
So sometimes I'll be like,
ah, there's this command.
I think it was this.
But if you get it wrong,
then it's like you get zero help, right?
If you get one character wrong.
But this one is, if you get close,
can you get close
and we'll give you some autocomplete on that.
That's pretty cool.
Yeah, that's great.
Because you might like be searching
for a file name or something like that.
Yeah, yeah, exactly.
Exactly. Did you see that? There was an XKCD, I think, Because you might be searching for a file name or something like that. Yeah, yeah, exactly.
Did you see that?
There was an XKCD, I think, or some other comic of somebody.
Now it's a different one, but somebody scrolling through their history for like an hour to get LS.
Yes.
No, I'm definitely going to try this out.
This is pretty good.
Can you scroll?
Oh, you're going on the XKCD.
No, sorry.
Can you scroll up to the commits?
Number of commits?
Yeah, 350.
Yeah, this has the look of a project that's been refined, doesn't it?
Yeah.
Yeah, it does.
I don't know quite how long it's been around.
But yeah, it looks like the oldest super obvious one is 14 months.
Yeah.
Yeah.
It's continuous integration. It was last configured 14 months ago, let's say.
But yeah, this is.
No, it's the docs.
The docs were two years ago.
Okay.
The docs, there you go.
I think this is nice.
I wasn't sure I would want to use it.
I'm like, oh, this is interesting.
And people might, then I installed it.
I'm like, oh, this is pretty cool.
I like it.
You know, all the cool stuff I like in Python, like PyM and PipX and things like that,
they all have a section about using this with fish, you know?
And so I'm always taunted with my lack of foo
when it comes to terminals.
Yeah.
Yeah, I made the switch to ZShell.
Oh, my ZShell.
I'm not looking back.
Love it.
All right, Patrick, who will be out in the live stream,
says McFly seems really interesting. I'm using ZShell for a month now and always. Love it. All right, Patrick, who will be out in the live stream, says McFly seems really interesting.
I'm using ZShell for a month now
and always thought the control R search lacks features
compared to other plugins for sure.
Absolutely.
And then David Pochon out there says,
you covered that LS joke in the show.
Yeah, that's beautiful.
I love that one.
It's been a couple of years, I think,
but it was a good one.
Well, we don't have a joke history command, so.
Yeah.
Oh, McLaugh.
He's writing McLaugh.
Something we never cover on the show is textual.
So why don't you tell us about that, Paul?
Sure.
Switching over to me.
Yep, we got me.
I think it was episode 241 when you had Brett on
and Brian led with Will McGugan talking about Rich.
And I'll quote Brian because it was funny then and it's funny now.
How can I not have heard of it? I'm a fan of the podcast and Brian loves this tool.
So I'm going to go back to the well with the thing that was spun out of Rich at that time,
Textual, which has been covered, but I want to talk about a particular aspect of it.
It was kind of interesting to me as a pattern.
And then having a little debate where the two of you tell me that I'm wrong
and really ancient about this.
So I've traditionally been against the convention over configuration camp
in the world of Python. I come out of kind
of the Zope tradition, the Pyramid tradition. Pyramid is like, oh yeah, well, here's a
configurator object and it does 15 trillion things that you really ought to care about, but don't.
Because Chris McDonough has really great design sense, kind of Goldilocks, knows exactly what to put in and leave out.
And I just, that whole worldview fits into my head. And so I have this dislike about magic names,
magic file names, magic variable names, can't auto-complete them, can't refactor, can't navigate.
If you can't memorize it and keep it all in your head, you know, and Python is explicit over implicit, blah, blah, blah.
I prefer like actual symbols that smart editors can operate on and not have like a little bit that's going on with data classes right now, each individual tool having to wire up special support
for that template language or that this, that, or the other thing to look for these magic hand waves but will had this thread
and actually i should bring the thread up uh will had this thread on twitter which made me feel a
like i was a little bit wrong and b like he had solved some of the issues that i had with it
so what he wanted to do was remove some boilerplate.
And in this, he gave some examples about before and after. Here's the screenshot of it. So that's
before. And you see like in here, watch how much this changes when you go to this. So kind of the noise, the ceremony, a lot of the stuff was reduced.
Okay. Now, anybody can look at this and say, wow, that's great. If you're optimizing for
writing code, if you're optimizing for reading code, and you want to walk back up to this later
and know that there are some special semantics that, you know, if the name starts with these three things,
then the next thing is kind of a thing that is a, et cetera.
And so I worry about, I worry about those kinds of things,
but he had done it in a way where my pie would still help you some.
And one of the innovations he had that I felt like, let's see,
do you see, do you see me on Twitter? No, you don't,
because I'm in the wrong window. Sorry about that. Okay, my apologies. So into this screenshot,
you see a before and after. Brian, you see that? Yeah. All right, good. Before and after. And so
he's talking about boilerplate removal in this thread and some of the decisions such as like this.
For any of you that do type annotations, type hints, you'll look at this and you will say,
oh goodness, the type hint went away. This is actually a perfect example. And you look at this
and you think, I just lost the typing information and I believe in type heading.
Well, not really because it can be inferred,
it can be deduced.
Right, so for people listening,
the example is you've got like a variable colon type equals.
Sorry, yes, this is a podcast.
Instantiate, yeah, instantiate the type
versus just drop the type annotation on the variable.
But when you're allocating up the object right there,
like all the editors in my pyre are like,
you know what?
Thing equals new object.
That's right.
It could be that object.
Yeah, and in these like titantic battles about type pinning,
we forget that, well, you don't have to do all that typing all the time.
Python and type checker static analysis can figure this kind of stuff out.
So I looked at that and I was pretty, you know, I was probably kind of seduced by that.
But let me ask the two of you, maybe the audience as well.
Do you think that three months from now, if you walked up to your textual application,
would you be able to remember that he had done these things and that the right hand
side was telling you about the left hand side.
In order to save a little bit of typing, did I lose a little bit down the road and have
to load up my future self?
What do you think about that?
Brian?
Well, I'll tell you what I think.
Is there a separation of where this happens?
Like on the example that you're showing here, like object or variable equals new object.
I never need help with that.
I get super clear what that type is all the time.
Where it becomes not so obvious to me
is where I've got like a class or something
and it's got a field
and then I'm creating that object and passing it in.
If my PyCat still tell me,
oh, this thing is one of these because the only time you
ever use it is always passing this type.
But that's a separate file and I'm not looking at it side by side.
Then to me, that like starts to add additional work for me to keep track of in my mind.
The other one I would say is the autocomplete test.
If I'm working with thing, I say variable dot
and it goes zoom
and there's the list of things.
There's a good chance
I don't care about anything else.
Right?
Like did it autocomplete the thing
and did it tell me
if I put the wrong property field,
whatever on it
because it knows what that list is.
And if the magic name changes later,
will I get a red squiggle?
Yes, exactly.
Will the editor know that it was broken
and will it help me write
it so I don't have to look at the docs? I don't have to go to the source. I just use variable
dot and I just keep rocking until I really need to understand something. I would say that that's
where I come down on it. The third thing is, if this is not relevant here necessarily,
but if you're doing something like SQL Alchemy or Mongo engine or Django ORM,
so often what they do is they have like two flavors of the thing. I'm creating a class.
The class has a field it's called email. Oh wait, no. What is it? It's being set to a
new Mongo engine field of type string that has a regular expression on it. Wait, that's not what
I get at runtime. At runtime, I get a string.
At code time, I get this.
So for those, I will say field colon type is string
equals Mongo field is a Mongo string or whatever,
or SQL can call them of type string
because I want it to be explicit
that it's not really what it says there
because often the editors will give you column information, which doesn't make any sense.
Anyway, that's a long answer, but I gave Brian some time to think about his position here.
I'm actually just very impressed with Will's design decisions on a lot of things.
And there may be some magic hidden in there, but I would rather have less code to look at.
So less code to look at means less things to get wrong as far as I'm concerned.
I am coming down with you on this one.
I've been working for a long time on kind of a long project about static analysis and Python templating that is driven by type hints.
And looking at what he's done has made me step back and think, wow, there is some there's something some things you can do without throwing out type hinting that improves the readability and removes the boilerplate while keeping people on the rails.
Back to what you said about Will's design decisions,
looking inside the code of Textual is really fascinating to me. Fascinating enough that first
today, Will announced that he is changing his job status so that he can work for the next three
months on open source completely rather than at night and is looking to meet a target for GitHub sponsorship.
So let's all go out there and sponsor him so we can get these delicious looking treats
that he keeps giving to us.
But second, I'm interested enough that I want to join the freaking project and learn from him.
I need a reactive system.
He's got one.
I wouldn't even know how to write a test for it.
And he's got that too. So I wouldn't even know how to write a test for it. And he's got that too.
So I'm with you on that.
I love the way he writes his code, the way he talks about his thinking in public while
being a gentle and encouraging public figure.
Yeah.
Well said.
Absolutely.
Well, very, very cool stuff.
There's a lot of neat things coming out of there.
I think a lot of people's reactions are like astonishment. Like, wait, that's a terminal. That's insane that it does that.
Yeah. Ah, on to the next. Speaking of testing, have either of you ever used DocTest? Paul?
Yes, I have. So I, way back when, when I started blogging about testing,
I thought it'd be fun to compare the test frameworks
because I wrote my own.
It wasn't fun.
So I looked at unit test.
I looked at doc test.
I looked at pytest and nose also.
And I actually thought, you know, maybe just just I didn't think it would go very far,
but I tried to use doc test as a end to end test tool. It was difficult. And there's still some
cool things about doc test. So if people are unclear what doc test is, doc test is a package that's built into Python that you can write.
You can use it by saying python-m doc test and point it at a file, one of your source files.
And within your doc strings, if you've got things that are like the three, I'll see if I've got it here.
So the three arrows or something like the prompt, the Python REPL.
And you can type some examples in there.
And DocTest makes sure that the output really matches what you said.
So DocTest will go through and make sure your code examples within your code actually work.
This is a cool idea in principle.
In practice, it's very painful.
And a lot of the pain points come around, well,
I forgot to import anything. So you have to include the imports in there. Or I forgot to,
there's a lot of stuff that can go wrong. Now, PyTest adds some things. You can run
doc tests from PyTest. It's pretty cool. What we're talking about now is a new project or a project new to me called X-DockTest.
And X-DockTest, it's got a whole bunch of cool features.
One of the things is DockTest is a regexplate-based thing.
It pulls out the string, finds the code, runs it, looks at the output, makes sure they match.
X-DockTest uses a, whatever whatever the source tree thing.
Abstract syntax tree.
That's it.
Abstract syntax tree.
Yeah.
So it's actually parsing it better.
And there's a whole bunch of cool stuff you get with that.
The thing that I, there's some highlights in there.
Like one of the things is uh continue string continuation was painful because
you had to include the little angle bracket things you don't have to do that with x doc test
the thing that i love the most though is uh one of the defaults um uh in doc test is it does not do
string normalize it white space normalization you can turn on, but it doesn't do it by default. X doc test by default does white space normalization.
What that means is if in my code,
I cut and pasted stuff and added like a tab
or a space at the end of my string,
doc test will fail that because it's like,
oh, that string's not the same.
There's white space at the end.
I don't care about the whitespace at the end.
So one of the things that xdoc tests
is just fixes that right off the bat.
So it's going to be way more pleasant just to work with.
But there's a whole bunch of other cool features of this
that it brought in.
It has a more sane skip syntax,
although they kind of had to read it for a while.
You have to say plus skip to start the skipping
and then minus skip to turn it off.
Yeah, anyway, but it's pretty neat and flexible.
And I think if you're going to start out
trying to do doc test stuff,
I would totally use xdoc test.
Plus it has a built-in PyTest support.
So if you have it installed,
you can say PyTest dash dash xdoc test
and run it on your
code it'll run fine so yeah very nice oh you're two for two on predicting what i was going to
talk about so but i what i really want to hear you do is say abstract syntax tree in a daffy duck voice
no you no way that'll be in the bonus track brett cannon made us sing a song um from like
ren and stempy or something like that oh my goodness yeah was it that it was no it was uh
pinky in the brain that's what in the brain yeah yeah yeah it's all from the same general genre
era we should do a ren and stempy skit sometime sometime. That would be fun. God, Ren and Stimpy was awesome.
The peak of civilization.
Yeah.
The red button.
Okay.
Don't press it.
All right.
What's next?
I'm next with this one.
Okay.
I want to start with some code and then tell you more about it. I want to tell you the code and then you can think about how complicated is it and then what is this accomplished?
So here's some Python code.
It creates a little LED.
It's for like some embedded thing.
It imports the LED, imports time and imports random.
It says LED equals LED number 17 while true.
LED on, sleep one second.
LED off, sleep for between 45 and 60 minutes.
That's the entire bit of code.
What does it do?
This is how I automated my
standing desk with a Raspberry Pi. Pretty awesome, right? Yes. So this one comes to us from Joe
Ridley. Thank you, Joe. And this is by David Kong. Apparently he's into sort of hacking his
productivity in all sorts of ways. So he got a standup desk and he said, I have this cool automated standup desk. You can push a button
for up, push a button for down. You have presets of like where you like the up, where you like the
down, but he didn't press it very often. So he's like, well, why am I not pressing it? Because I
am lazy and I want to stand up. And then, so he put reminders on his phone and says,
you want to stand up? He goes, no, I don't want to stand up right now and then he said well what if it just did it and i had to like adjust to it right so he went along
and he there's like a couple buttons little programmable bits and he just pried the face
plate off of the control surface of his automatic desk you know it was a works desk so whatever if
it breaks i guess right pry that. And it just has a few
little like pins in the back. And if you push the button down, it completes the circuit. And he's
like, well, really all I needed to do is stand up. I can push the sit down button when I'm tired of
standing up again. And so went through about like, how do I do this? I just need to connect
something that'll trigger electrical current on one of these, these bits here. So I said, well,
maybe I could use some little
like super micro thing, some small things.
And you know what, actually for five bucks,
I can get a Raspberry Pi Zero and you'll go crazy,
get a case and an SD card and all that
from Adafruit for five bucks
and just write some Python code.
And then you connect these little pin areas,
like number 17, for example, to a circuit.
And instead of turning on the LED,
it just sends a current over to that little thing on the desk.
And it'll make it go.
Isn't that awesome?
That's great.
I want to do that.
I need a standing desk first, though.
I know, me too.
Here I am saying,
Will, who is in the audience,
has magic method names.
How do I know? How can I tab complete? Will, who is in the audience, has magic method names.
How do I know?
How can I tab complete?
And this thing's like, hook it up to terminal 17.
I mean, oh, not 18.
All right, great.
Exactly.
It's pretty janky.
No, but that's great.
That is, I've got to.
You have a standing desk?
Stand up desk. It's a different brand, but it looks like the exact same panel.
Well, stay tuned
so one of the things is like i don't really need a ui but maybe just a terminal and how do i talk
to the raspberry pi so um david goes on to talk about well how he set up um an ssh shell over to
his raspberry pi from his macbook using a usb cable because he's it's on the desk anyway and
then just writes this little bit of code that I talked about, movedesk.py, and off
it goes.
Soldered a few things together and then just taped it to the bottom of the desk.
And now you have it going.
I would contend there's a few minor upgrades that should be added here.
Maybe a time check.
You may freak a custodial person out if they come in the middle of the night
and they go to get the,
if they go to get like-
The clone army has been activated.
Exactly.
We're going to empty like the trash bin
under your desk and it goes,
you would, I would run for it.
But if that were me,
but you know, so maybe like a web service call
to check the time or just check the time and go, really just do this during work hours.
And like, honestly, this was a pre-COVID thing.
So it randomly raises and lowers it?
Yes, between 45 and 60 minutes on the hour.
Okay.
That is fabulous.
Yeah.
If you look at the comments here, this is where you got to hang tight, Paul.
So people are digging it um someone
down here a little bit further says i have something called a very desk but it turns out
when i peeled the front off of my very desk it had exactly the same control board on the inside
how about that yeah so paul you if it looks the same it may well be the same because someone else
was saying that they did now my desk is going to be smarter than me i mean i've gotten used to my watch being smarter than me but it will just have more will
power than you because you're like i don't really want to stand out well i can't reach it anymore
so i got to stand up box and the hedgehog yeah exactly all right well that's all but i thought
it was a i'm always thinking of like we have these super cool devices that cost like five bucks and
it's they're so easy to program but i just I don't usually have anything cool to do with them.
And this seems entirely attainable.
Yeah.
Yeah.
I think maybe hooking up a height adjustment
with random adjustment to my webcam would be cool
so I could just have different angles throughout the day.
What if there's like a pulley system
that after a moment yanks the chair
and if you don't get up, it's just going to dump you.
Like a little bit more urgency to the minute.
To wear a helmet at work.
Exactly.
Or score a gun if it finds you're still sitting or something.
Puts my coffee slightly farther away.
Exactly.
All right.
Paul, what's your last one?
This was a really interesting one for me.
I was on vacation in heaven in August. And two things I did was when
I was at the beach, I had the beta of Brian's book. And when I was back at my mother-in-law's
house, I was taking my six related Python projects and teleporting them into the future using the hyper-modern Python cookie cutter.
And what do I mean by that? Well, if you're doing a Python package, a library or something that
you're going to distribute on PyPI, you know, Python development's gotten, the bar has been
raised, let's put it that way, on quality control and tooling and things like that. And my good friend Brian Ocken long ago, 10 minutes, mentioned about X-Doc Test,
which is also on here, I believe.
Yeah, X-Doc Test.
Along with 57 other things you might want to do, like Dependabot and Flake 8 and Precommit
and MyPi and Black and GitHub Actions and all these other things.
And individually, they're achievable.
Collectively, they are a go on vacation in heaven, delete your repository and start over.
That's what I did.
I deleted all my repositories and started over with poetry and things like that. This cookie cutter isn't just great
because it's a cookie cutter
that gets you in the ballpark out of the box.
It is a user guide that explains all the decisions made,
including the why.
It's like teaching you how to become
a modern Python packager programmer,
someone who's going to distribute stuff.
And in fact, there was a blog, a series of blog articles before he did this.
Let's see if I can find that.
Yeah. So often you'll see these articles of what you should do,
and then you just have to go do it.
And this is like, here's what you should do.
Indeed.
And then you run this command and then it's done.
But now you know do. Indeed. And then you run this command and then it's done. But now you know why.
Indeed.
And in fact, I found the part you just described to be more valuable than the cookie cutter.
Yeah.
Because the last thing I wanted was to be teleported into 57 things I didn't understand.
Yeah.
And so just for the two of you, if you could look through that list, maybe anybody in the audience look through that list.
How many of these are things,
Brian,
you've been distributing packages recently.
How many are these?
How many of these things are in your list of guilt that you're not doing?
Yeah.
No,
a lot of these,
a lot of these are great.
Some of these I'd like to add,
like I'm not doing much type checking.
I'd like to do more type checking.
Some of the choices, I just don't agree with the choices.
So I was actually considering doing a fork of this with the choices that I would have made.
Knox is a cool project, but I've got no problem with Knox.
Yes, I knew you would say that, and I agree with you.
I would change that, too.
And I know you said you like poetry. I know a lot of people love poetry.
It just doesn't fit my brain. So I don't use poetry. But that's I'm only 50 50 on it. I'm
fighting it. But a whole bunch of other stuff, like you said, things that maybe you didn't
consider like black and prettier. I don't think I use both. So I don't know what
prettier gives me the Black doesn't.
JavaScript and mark down the things like that. JSON files, non-Python.
Oh, okay. Don't know what Release Drafter is. That looks neat.
The whole Release Drafter thing, I don't know if either of you have ever looked at Release Note Automation in Python,
but there's a number of packages, semi-dead, and most of them result in this dance
of if you push before this thing runs, you can't get your notes on the tag. And so this is hooked
up with a GitHub action, which makes a draft of your release notes for you as part of the
merging a pull request to bump the version number process. It's just
fascinating. I would have never figured this out, man. Never. Okay. We got some cool comments.
One here, it's not as from Exelon. Yeah, that's a good point. It's not as hyper modern as the
title suggests. It's often pretty solid advice. I'm not sure if what he means by solid is a compliment or an insult.
I think what he means is hyper modern.
At least when I read it, I was like, the last thing on earth I want is bleeding edge on this stuff.
And then also list of guilt would be a good title for this.
Yes.
One of the things I want to, I point out the article series.
So at the top of this,
what we're going to link to,
there's a,
it links to hyper modern Python.
It's a list of articles.
The artwork in this is amazing.
So he's using some,
some freely available Japanese,
really clunky thing.
So yeah,
well said,
did you read any of the articles?
Oh,
well,
I read all of them when they when they first appeared.
But it looks like there's some newer articles that I haven't read yet.
So, yeah. Yeah. So Claudio, mega kudos.
That's another project I should join because there's a couple I would like to teleport him from Sphinx restructured text to Sphinx Markdown. Oh yeah, definitely.
Which is what I've done in my,
each time I did this,
I did a commit immediately to replace it.
And it's a little bit of work.
And so it's a contribution I could actually make.
Yeah, Sphinx Markdown is the reason why I use Sphinx now.
Very good, very good.
So one last thing I'll close with on the X-Doc test, Brian.
I was using it from HyperModern Cookie Cutter Very good. Very good. So one last thing I'll close with on the X doc test, Brian, uh,
I was using it from hyper modern cookie cutter and I switched to this from Chris Withers,
Sybil,
uh,
which is,
uh,
Chris is an old time.
So Pista.
And so what he does is he lets you,
this is not about doc strings in your code.
This is about blocks in your Sphinx blocks of code in your Sphinx and testing them.
But you wind up with this doing something PyTesty,
and this lets you have fixtures and all these other things
available in your doc test blocks.
Cool. We'll check it out.
Yeah.
Yeah. Super, super cool.
And actually, Solid was intended as a compliment there yeah very nice all right brian you got any extras to wrap it up
i don't other than just an apology uh sorry um about the solid comment oh well i know that was
good uh paul good anything else yeah i had a chance chance um i guess at the end of last week uh if you've been
to pi con before you'll know uh the some of the folks in the psf uh bessie walsh esky who has
been with the psf forever and ever was with o'reilly before that. She is now with OSI, the Open Society.
God, I know I would say that.
Open Source Institute.
I spent 10 years on a project
with the Open Society Institute,
the other OSI.
And she is working with OSI
on their messaging and fundraising
and things like that.
And it's a very interesting problem for us in the
Python community that's similar to the problem we had with the PSF, getting people to pay for the
comments, if that makes sense. Now, the comments for the world of open source is a lot squishier
and the value proposition is a lot more indirect relative to the world of Python.
But I feel like there is a big there there that the world of open source is still relevant and still has important next problems.
There is a commons. There are things that will need to be done and we need a neutral
agency that is an advocate for the commons to work on things like that. So she and I discussed
what's next for the commons, things going on at OSI. If any of you were around in the beginning
of the words open source source you know the problems that
were being solved then they feel like solved problems now but that's an open question and
sometimes problems don't have a way of staying solved so keep an eye on osi keep an eye on what
betsy and stefano and others doing. Keep an eye on open source itself
and maybe share some thoughts in the show notes
or anything like that.
What do you think is the big mission for open source?
Yeah.
Maybe reply to the Twitter thread announcing this episode,
which will be out shortly.
That'd probably be the best place.
Or the YouTube live stream chat would be good.
Good places for that.
How about you, Michael?
Do you have any extra bits?
You know I do.
First of all, I want to just really quickly on the hypermodern thing throughout.
Remember we talked about readme.so?
Oh, yeah.
Oh, gosh.
And this is readme as a service.
This is good to generate your readme
and then you can use the release note thing to keep it going.
So, yeah, I just want to give another shout out to that because the idea
of readme as a service blew my mind.
Does it do badges? God, badges are so
hard. I know. If it doesn't do badges
it better. That would be an awesome upgrade.
Okay. A couple of quick things I want to throw
a shout out to. These are at the bottom of the show
notes. ActiveState, you know,
they're one of the packages
distributors of more
full-featured, holistic, sort of prepackaged Python distributions.
They are running a survey called the Software Supply Chain Security Survey to supply chain security of PIP vulnerabilities.
IPI, package pollution vulnerabilities, and stuff like that are big deals.
So they're interested in running
a survey. So I thought I'd give a shout out about that. People can fill that out. Python 3.9.7
and 3.8.12 are out with, I think 3.9.7 might have some very minor new things and 3.8 is just a
security update. So bug fixes, but the 3.9.1 didn't speak to me as anything super major,
but you might check it out
there's a few uh security things in there about like if you pass this to like the ip class or
something like that it could be an issue but i don't really think there's anything super important
there but uh no brian this one let me read the little description for you this one here comes
from shlomi lanton says uh b, you talked about having a history of all
the files in a GitHub repo and finding out how long the oldest one, like we were just looking
around like, how old is this project? Maybe two years, looks like lasting change. So he wrote a
thing called Grandpa. And the idea is simply find the oldest modified files in the repo that you can
run it standalone. You can make it a GitHub action and so on. So it just oldest modified files in the repo that you can run it standalone. You can
make it a GitHub action and so on. So it just goes through and finds the oldest files. Last week,
I talked about WakePy, which will let you keep a process awake. No, keep your computer awake while
your Python process is running. You do like a context manager, you know, with keep awake,
do the stuff you don't want the computer to go to sleep during. And then when you know, with keep awake, do the stuff you don't want the computer to go to sleep during.
And then when you leave the computer, it can go back to sleep. And I said that there was a problem on Mac OS, but PR is accepted that things back to good. So thank you for that. Really quick shout
out to some, um, oh my Z shell, not my Z shell, oh my posh shell. Look at all that good stuff,
Brian. That's, that could be your, that could be your, um, power shell on windows.
Does it have VI key bindings?
If not, I can't use it.
I honestly don't know.
Anyway, I think it's pretty cool, but people,
it's not just for PowerShell.
It just happens to be one of these really nice extensions
that also works for PowerShell.
Oh, really?
Yeah.
It took me forever to know what Posh meant.
I'm like, Posh, what shell is that?
Posh is PowerShell, right? It probably is, actually, yeah. It took me forever to know what posh meant. I'm like, posh, what shell is that? Posh is PowerShell, right?
It probably is, actually.
Yeah, it probably is.
It sounds cooler than PowerShell, though.
Okay.
Cool, cool.
All right.
I think that's it for those.
Are you all ready for a joke?
Yes.
All right, here we go.
So here's a tweet from MonkeyUser,
at is MonkeyUser,
and they have a mess,
they have like this sort of planning diagram here,
like a flowchart, if you will.
Remember a flowchart?
But this is like real high level.
It's about trying to find a meaning as a software developer.
So if the person enters to the workflow,
quit, question mark, yes or no?
Yes.
Do you have paid time off?
Then what you can do is you can go in and you change your JavaScript.
I think it's JavaScript.
Change your JavaScript framework.
Will you acquire new skills?
Are you burnt out?
No?
You go back, you change your JavaScript framework again.
It's a little starving.
Have you changed your JavaScript framework in the last two months?
If no, then you need to change it again.
It burns. it burns.
Yeah, you've got some backlog here.
It goes to in progress and that gets shipped.
It gets done.
You get paid.
Do you have burnout?
Yes.
Are you dead?
Whoops, not yet.
Do you have paid time off?
Then you can change your JavaScript framework again.
No, then you ask, has it been changed in two months?
If no, then you change it again.
Otherwise you go to the backlog.
And I thought this part right here, Ryan,
you might particularly like, is it ready for QA?
Nothing goes to that.
It's just like an orphaned input box right there.
This should be the logo for HTMX.
Yes, it actually should.
Yeah, this would be awesome
because it really, it just tells you
the churn and another person walks up and says hey are you trying to find a new workflow for
how we're working this no i'm trying to figure out why i'm still doing this well there's there's
no way to go back to quit and there's yeah yeah and you found the Easter egg. Yeah.
Well, also, why is there still a separate QA department?
I love the leveraging of paid time off.
Yeah.
Backlog.
Backlog is like an afterthought. If there's nothing else you can do, maybe you can work on the backlog.
Yeah, exactly.
Nice. Awesome. Thanks. That's it awesome well thanks that's it yeah that's
it for our show brian thank you as always great to have you here and paul thanks for joining us
thanks for having me love the show love everything the two of you have been doing for the last few
years and hope to tell you this in person soon but probably yeah That's wrong. You said for me to interrupt you
and tell you when you were wrong.
I forgot to.
Okay, great.
Keep happy thoughts.
Do you promise not to cut your hair
until we see each other again?
Yes.
Yes?
I want to be cousin it
by next year at this time.
Love it.
All right.
Bye.
Bye, guys.
Thanks for listening to Python Bytes. Follow the show on twitter via at python bites that's python bites as in b-y-t-e-s get the full show
notes over at pythonbytes.fm if you have a news item we should cover just visit pythonbytes.fm
and click submit in the nav bar we're always on the lookout for sharing something cool if you want
to join us for the live recording just visit the website and click live stream to get notified of when our
next episode goes live. That's usually happening at noon Pacific on Wednesdays over at YouTube.
On behalf of myself and Brian Ocken, this is Michael Kennedy. Thank you for listening
and sharing this podcast with your friends and colleagues.