- Podcasts
- Python Bytes
- #361 Proper way to comment your code!
About this episodeTopics covered in this episode: The many shapes and sizes of keyboards appeal - a CLI framework from Larry Hastings Graphinate: Data to…
- The many shapes and sizes of keyboards
- appeal - a CLI framework from Larry Hastings
- Graphinate: Data to Graphs
- A Disorganized List of Maintainer Tasks
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#361 Proper way to comment your code!
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 361, recorded November 21st, and I am Brian Okken. And I am Michael Kennedy. And this episode is brought to you by Scout APM. Thank you, Scout. Listen to their portion later in the episode.
If you'd like to connect to the show or with one of us, we're all on Phostedon, on Mastodon. So we're at mkennedy, @brianokken, and at Python Bytes. And if you'd like to join the show and watch it live or comment in the chat while we're recording, check us out at pythonbytes.fm/live and be part of the audience.
Yeah, it's fun to have people be part of the audience. Not required, certainly. Not intended to be required, but fun to have them there. Yeah. What do you got for us first? Oh, well, very excited to be back together on the eve of Turkey Day. The Turkey Eve. So happy Turkey Eve by the eve of Turkey Eve.
Eve, Eve. It's the eve squared. Yeah. I don't know how this multiplies together. Let's start talking about something snarky, aka Brett Cannon. So Brett Cannon did a nice write-up here about different keyboards. And Brian, I know you're a fan of ergonomic keyboards. I am definitely a fan of the ergonomic keyboards, having had serious RSI issues at one point in my career.
So choosing a keyboard is something I wish I'd paid more attention to when I was younger, but is super, super important. And Brett had his nice write-up on it. So that's what I'm going to cover today. Cool. So basically, he says, look, here's what I care about. I have a bunch of different concerns, right?
So, you know, for him, it was more his back that was causing him problems. But he was looking to get a fully split keyboard. He went from something kind of like my keyboard, which I'll give a shout-out to in a second, to a completely split, which means the keyboard, the left, the part your left hand touches and the part your right hand touches are not attached, at least not physically, maybe through a wire just so they communicate.
So, well, okay, how do we go? It talks about all the considerations, all the things that he cares about, and then goes through like a nice long list of things, right? Yeah. What has he used before? The requirements are fully, must be fully split because he's using ergonomic one that's not fully split now.
Okay. Okay. First of all, he says, Hey, look, I'm using, I think he was using, or at least was considering and like put it into the category of the Microsoft Surface ergonomic keyboard. That's a fine looking little keyboard right there. Yeah. It's like a full size keyboard or a hundred percent keyboard where it has the numbers and all of that.
The numpad thing in addition to the numbers on the top, of course, it's fixed tinted, I guess you would call it, right? It's got a really good curve to it, but the curve you can't adjust. You can like lean it. So the starting point where like your arms start to touch is higher than the other one if you want and so on.
But I actually got this when it first came out, maybe something's changed. But when this first came out, I'm like, oh, this looks great. I'm going to give this a try as an alternative to the one that I use. And you know what? Unbelievably, even though it's Bluetooth, it doesn't work on macOS at all.
So if you want to use this and you're using Windows, it looks pretty cool. If you're not using Windows, it's kind of more like paperweight than it is a keyboard. Maybe something about this has changed. But I mean, I took it when Microsoft had Microsoft stores like Apple stores. I took it back and I said, guys, I bought this.
Possible. Possible. I use the Microsoft Sculpt ergonomic, which is not the Microsoft Sculpt Surface ergonomic. Oh, this is the one I tried. And that works everywhere. Yes, that works everywhere. That works everywhere. And it's smaller and it's lighter. And I think it's actually better across the board having had both.
This one is fine. The Surface one. No, no, no. This one doesn't work. Okay. So another one, he said, like, some people really like the Apple Magic Keyboard, which is like more art, less functionality. You know, it's very standard for Apple hardware, you know, save them, put the Macs and iPhone stuff aside.
But like the accessories, it's like, can we just make it beautiful? I don't care if it's the most uncomfortable thing you've ever touched, like the Magic Mouse or anything. This is like, I want Carpal Tunnel next week. I don't have it now. How can I get it? Let's try this. So I don't necessarily recommend that.
It's just. It's because it's unusual. Well, it seems unusual. Not in a bad way. But it's a split keyboard where you've got like basically divots where your fingers go because your fingers are like, you know, they're not flat like a keyboard. They're curved around. So this. It's like if somebody dug a hole for the keys.
So your thumbs can do it. Yeah. And I really love that. And one of the first things I do is because I'm a VI user or Vim user is I map one of those middle ones to escape because yeah, I want to address it. It's programmable too. So it's nice. Yeah. That's one of the big, as you started to explore it, it's one of the big areas is like, what does your thumbs do versus, you know, not just space bar, but your thumbs become way more active.
Yeah. And by programmable, I don't mean that you have to like write a program for it. I mean, it's you could just, there's like a key sequence. You can say, I want to remap this key to this other place. And it's, it's pretty easy. Yeah, absolutely. All right. So that was one that was on the list of considerations.
Like where there's like a, it's not a ball, but it's like a stick. That's like a, like a joystick for the mouse almost. Yeah. Yeah. This one looks pretty interesting. It's lit up. You can, I think program it, but this one's quite cool. It's fully split and it's got these little bars for the tenting.
So you, you can adjust like how, you know, side to side it's like bent, which is pretty neat. I think, what do you think about this one? I'd, I'd like to use that, but one of the interesting bits is the middle keys are, they're just blank. Cause you can map whatever you want to them, but I, and a bunch of other blank ones.
I'd rather have some replacement ones to, because I'm really not going to remember how I mapped them. just got to Sharpie them. Sharpie thing. I guess. Yeah. And no kidding. No kidding. yeah. But yeah. The other thing that I really, that, I think about a lot is like these keys look like they have a long up and down, like key throw, like the travel of the key seems high and the travel of the keys on the sculpt ergonomic one is incredibly small, like probably less than on a Mac book.
Since you're a fan of Kinesis, have you looked at this thing? No, it's flat. You can, no, you can tilt it. No, but it doesn't have the divots. Oh, I see. I see. I see. Gotcha. I know what you mean. It has no holes dug for the keys. Yeah. Yeah. This is pretty interesting. You can like tint it a lot, but it is kind of just like a, if you want the least weird keyboard, but you want to separate it.
Lots of adjustability on like how it's oriented and things, which is kind of cool. Very thumb friendly, but no, no markings, right? For the programmability. So you're going to have to need a white Sharpie for this one. Yeah. Yeah. Yeah. Hacking keyboard was a Barry Warsaw recommended this one, which it comes with a built in track ball looking thing in the middle for one of your thumbs.
Got it. Content. Definitely looks like a content. And the one that he actually went more, I believe went for is the Digma Defy. So you can defy your limits with this one, which looks pretty genius. Well, it's kind of so intimate. So intimate. You can hardly see a picture of it, but links up for all these in the show notes.
But this one, like this one is thumb heavy. Brian, look at how many options your thumb gets to play with there. Oh, I like it. Yeah. Yeah. Yeah. Yeah. So apparently this one takes a little while to get, but anyway, I wanted to go through this because I know there's a lot of people out there who might.
So I'm not going to try it. Like honestly, it's worth not doing something that's just square. That is your laptop. Yeah. Also stand up and walk around to shake yourself out once in a while. Exactly. 10 hours sitting. We'll get a chair that just every so often, like the chair just springs you over in the back and flings you out.
I know that, like, typer was using type hints, but it still has, typer still has kind of a lot of boilerplate that you have to do. And so this is a very minimal API to get things done. And I'm pretty excited to try it. Also, look at the contributors. So there's only five contributors, but it's Larry Hastings, Hugo, Brett Cannon, Hinnick, and I don't know Peter, but wow, already.
Yeah. Pretty cool. Yeah, that's pretty cool. Looks very interesting. So anyway. Nice and simple. Nice and simple for command line interfaces. Worth a look. Okay. Do you know what else is worth a look? Mm-hmm. I would like to tell everybody about Scout APM. So thank you, Scout APM, for sponsoring this episode.
Are you tired of spending hours trying to find the root cause of issues impacting performance? Then you owe it to yourself to check out our sponsor this week, Scout APM. Scout APM is a leading Python application performance monitoring tool that helps you identify and solve performance abnormalities faster and easier.
Scout APM ties bottlenecks such as memory leaks, slow database queries, background jobs, the dreaded N plus one queries problem common with ORMs, and more, directly to source code so you can spend less time debugging and more time building. You'll love Scout because it's built for developers by developers.
Okay. Something called Graphinate. That is the verb of to make a thing a graph, I guess. It is also a noun, the name of this project. Yeah. So this one comes to us from, one second. I ran Rivalis. And this is a project. It's Graphinate. Graphinate is a Python library that aims to simplify the creation of graphed data structures from just pure data sources.
So probably the best way to get a sense of this is just look at some examples. So we go down. It's Badge. It's GetHub ReadMe Badge game is strong, by the way. Yeah. Wow. Yeah. So if we go down a little bit, you can see some examples. Like here is a visualization of a Python AST that looks a little bit like an advanced molecule based on benzene, but like a bunch of stuff coming off of it, I guess.
Like a hexagonal thing in the middle. It's kind of cool. And then here is a relationship of some repositories and dependencies on GitHub. Very cool. Here's webpage links visualize. Ooh. Those are all nice visualizations, right? Yeah. That's beautiful. It looks like Dandelion fluff all connected together.
Yeah. You can almost blow on it and like take out a whole segment of the internet. Yeah. And so the way to make this happen, if you go back up here, is you write a generator that defines the edges. So however you might iterate over your data source, I suppose you could even use like recursion with yield from and all sorts of things to like go through hierarchical data models and whatnot.
Yeah. Yeah. It is. It is pretty cool. So anyway, I thought there must be a lot of people that want to have these graph databases. And Mike Fiedler says graphs, not charts. Important distinction there indeed. Yeah. So if you're doing graph type of work, even cyclical graphs seem to be supported as you can see for a benzene example.
Instead, look at the project and see where you can start getting involved. The more help maintainers have, the more they can get done. And I really love this message. Partly is looking through this list and saying, huh, if there's a project I want to work on, or I'd like to have move faster, what could I help?
One of them, I'm not going to be able to find it right away. Oh, here it is. Turning questions and answers into documentation improvements. So when you get questions on Mastodon or an email or something saying, hey, how do I do this? That's a great place to put it in the documentation, but that is work.
That's extra things that need done. So it'd be great to even reach out to a maintainer and say, hey, is there any parts of the documentation that you'd like help with or something like that? So I kind of love this and I'm kind of overwhelmed. My list is not this big, but wow, David, thanks for all your work.
So if you look at Flask and GitHub, there's a little bit of attention on that project, right? Like 65,000 stars, 16,000 forks. That's a high level of maintainer business, right? Yeah. Yep. Yeah. There's a lot going on there. And Click. I've been kind of using Click more also. So there's a good projects.
That's right. Yeah. So very cool. It's almost like a reverse lookup of how can I contribute to open source? Yeah. And I actually, this is not, I think we covered like non-code contributors. This is all technical work. It's not non-technical. It's technical work to like answer questions and filter PRs and things like that.
Yeah. All sorts of great things to help out with. All right. Well, those are our topics for the day. Do you have anything extra for us? I have, I believe, three extras I want to cover real quick. Got a quick glimpse of them there as I was just showing the stars. First of all, in the weird world of marketing, it is Black Friday as of Monday.
As of this, yeah. Starting this week. Yeah. I'm not a big fan of it, but people really appreciate it. I know they wait up for it. So over at Talk Python Training, we have a different deal this year than we had last year. And there's two cool aspects of it. So I just want to give a quick shout out and let people know like, hey, if you're looking to take a course now would be in affordable time to do so.
And there's a good cost. So what I'm doing this year is I took five of our most popular courses or most anticipated courses that maybe are not even 100% done, but are almost done and put them out as early access. So we have Visual Studio Code for the Python developers coming out, which is a really awesome course.
I'm just like, how do I change my Vs? Go to do this and that. And what am I doing? How do I make it do that? So this is an early access by Brian Clark and Cecil Phillip. And we'll be out in a little bit, but you can sign up for it now. It's like two thirds of the way done. So it's still lots to get there.
Async MongoDB with Beanie and Pydantic up and running with Git, like a more visual, more beginner friendly way to get going with Git. Effective PyCharm because I love PyCharm. And our beginner course, all those are 50% off for the week. So that's our Black Friday. Nice. And the other part is we are taking 10% of the revenue and donating it to the Hidden Genius Projects, which trains and mentors black male youth in technology, creation, entrepreneurship, leadership.
Basically, a lot of kids who are in places where they might not see a lot of hope or don't think tech applies to them. And they run even up to like 15 month long, not an accelerator, that's not exactly fast, but like mentorship journeys for them. And they've had like 10,000 students and we've done a lot of things at like PyCon and whatnot.
But people can check out the new Alpha. If you want to start seeing what's coming and the new version. I mean, we just got 3.12, but it's now time to move on and start adding features to the Alpha. What do you think? I think that's, sorry. I think that's great. I just reminded, I was reminded of a couple years ago, one of my kids said that they heard somebody at school say, did you know that this year Halloween's going to be on Friday the 13th?
Maybe a little bit backwards. No, it's not going to be. So this is actually a little bit old, but I just realized I was up my list to talk about and I skipped it. But the 3.13 is already underway. People want to check it out, get going on. Yeah, we won't cover the new features that they're playing in, but maybe we can cover that in an upcoming episode.
All right. That's it for my extras. Okay. Well, I just have a couple extras. I, this morning I met with the JetBrains and PyCharm team and did a webinar about, do you do enough testing, pytest to the rescue? And it was really fun. It was Paul Everitt and Helen Scott. And we had, had a lot of fun this morning and we had like 200 people show up, which was great.
And it's, of course, it's all for sale. And I was going to ask you this after recording, but do you think it'd be a good idea to do a Black Friday sale? Yeah, it might be. Okay. I suspect people would be interested in it. Okay. I'll probably set up that. So if you show up today before I get a chance and it's not there yet, I'll probably by tomorrow, I'll do have the Black Friday sale on.
Sometimes people can just mess up the comments or, you know, they might be inconsistent or they could just be boring. It could just not attract. Like you might leave the function with a hollow sense of this was just, there was no joy here. You know what I mean? Okay. Okay. So here's a image that says the proper way to comment your code.
Let me see how I can do. I did study math. So the function is called calculate circle area given and the parameter is a radius. Okay. Okay. And it does what you would expect. But the comment is even more than the function. It says in mathematical fields where circles weave with pies, grace, a mystic number.
Yeah. Yeah. I love also the, the, the, the, the, it's four lines of code and eight lines of comment. and, and that's never going to be wrong. right. I mean, that's, I think that's our takeaway is yes. As long as your comments are just loosely related to the code below it, it's probably not going to be wrong ever.
And with that, Brian, I bid you happy poem and haiku writing for your code. Yeah. I'm more of a limerick man, but you know. Okay. Fair. We can make that happen. All right. Thanks a lot. And thanks everybody for listening. Thank you for showing up and to the, to the live episode and everybody listening later.
