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


Transcript #241: f-yes we want some f-string tricks!

Return to episode page view on github
Recorded on Wednesday, Jul 7, 2021.

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

00:05 This is episode 241, recorded July 7, 2021.

00:10 And I'm Brian Okken.

00:11 Hey, I'm Michael Kennedy.

00:12 And I'm new here. I'm Jay.

00:14 Hi, Jay. Thanks for coming.

00:17 So tell us a little bit about who you are.

00:20 Yeah, so I'm Jay Miller.

00:22 I'm a developer advocate for Elastic, a company that does search using Elasticsearch

00:28 and many other fine tools that we create.

00:30 And I spend a lot of time working on podcasts, shooting video, helping other podcasters,

00:38 which we'll talk about later, and yelling at Michael and Brian as they're podcasting and they can't hear me.

00:44 So, yeah, that's what I do.

00:46 I would totally love to hear one of those.

00:49 Just like record yourself yelling at our podcast at the same time.

00:52 That'd be great.

00:53 So welcome. Thanks.

00:56 You're kicking us off today, Michael.

00:58 So where are we starting?

00:59 Well, we're going to start with some automation here.

01:02 And I previously had covered that if you go over to GitHub, I'm not logged in.

01:07 I guess it's not going to work.

01:08 But if you go to GitHub and you forked a repo.

01:11 So, for example, if you forked CPython, if you forked FastAPI, you know, whatever project it is you forked, all of those things are under pretty active development.

01:20 And very quickly, your fork will get out of sync with what's called the upstream, the thing that it was forked from.

01:27 And GitHub recently added this ability, which we talked about.

01:31 To go to a repo and press a button, it says your fork is behind.

01:36 Would you like to catch it up?

01:38 And you can click a button and boom, it'll catch it up.

01:40 So, well, that's neat.

01:42 But wouldn't it be nicer if you didn't have to do that, if it just did that on its own?

01:47 Like sometimes you fork something and you're actively making a bunch of changes to it.

01:52 And there might be merge conflicts and all sorts of stuff.

01:54 But a lot of times, I would bet the majority of the time, people say, that's neat.

01:58 I want to save that for myself just so I'm sure I've got it and I can do whatever I want no matter what happens to it, right?

02:04 Maybe we depend on Flask.

02:06 And who knows what could happen with Flask?

02:08 Probably nothing.

02:08 But let's just fork it just in case, right?

02:11 And you just want that to stay in sync.

02:13 So here is an article or walkthrough by Yash Walia.

02:17 It says, three easy steps to auto-sync your forked repo with the upstream, the origin thing that it came from.

02:25 Now, of course, you could go to a command line and run a bunch of steps to do this.

02:30 But what this does is it uses GitHub Actions.

02:32 So you come down here and you can go to GitHub Actions.

02:35 And basically, when you're choosing a GitHub Action, there's like this marketplace or this catalog of pre-built actions that you can choose from as templates or whatever.

02:44 And then it opens up a text file that you basically type in the bits that you need changed.

02:49 So you go to the GitHub Actions and there's one called Fork Sync with Upstream Action from the Actions Marketplace.

02:59 And you can see it says on the schedule once every day at 7 a.m.

03:04 What we're going to do is we're going to run on Ubuntu, I'm guessing Docker image.

03:09 It's going to check out your project.

03:13 And then it's going to pull the upstream changes.

03:16 It's going to add the upstream origin.

03:18 It's going to line up the branches, do the checkout, and then just merge that in and push it back.

03:23 So pretty straightforward to do.

03:25 I ran this on some projects and, you know, one of the recent changes at GitHub and Moves is to get away from like master branch terminology.

03:34 And now it's all called main.

03:36 But I had some that when I forked it previously and it was master and it became main.

03:41 I had some challenges trying to like I think I just chose poor examples to try to work from.

03:46 So I didn't quite get this working perfectly.

03:49 But people with more GitHub Action experience than I have, I'm sure they can make it work.

03:52 So this seems like a really cool way to just say, yes, I want to fork something.

03:56 And please just stay up to date.

03:58 This is definitely neat for something where you're actively working on it a lot.

04:03 I think if you're just trying to train something out and forking it for a little like play yard thing, I definitely wouldn't turn this on.

04:13 But like with a team where you're all working on the same code, you definitely want something like this.

04:18 Oh, I hadn't really thought about it from the team perspective.

04:21 Right. Because a lot of the Git flow with teams thing is fork it, make changes and do a PR.

04:27 I mean, also, sometimes people just create feature branches and do a PR within the repo.

04:33 But if your mode is to create your own PR, your own repo and then do the PRs back to the main repo.

04:38 Yeah.

04:39 I can see that this being really helpful.

04:40 Yeah. We use a method in GitLab where it's on the we have to the the main repo has to has to know where all the forks are.

04:49 But it does a push every time there's an update to protected branches.

04:53 I see. That's cool.

04:55 I was thinking about using something like this for some of the projects that I do where there are folks that will take data sets and they're just stored as CSV files and they're sitting in repos.

05:07 And I'm like, well, if I have access to this data and I want to do some project with Elon or another tool that I use, then I have to then go and just manually download their CSV file and update it every time I'm about to present on that data set.

05:23 Whereas if I just say, hey, I can fork their code and then build my project off of their repo and then set this up so that anytime they update that one area, it's it's just always up to date for me.

05:36 I don't have to think about it.

05:37 I don't have to go in and go, oh, hey, was there an update?

05:39 It's just like constantly running in the background.

05:41 And I know you mentioned, Mike, at the beginning, like GitHub is working to make a lot of this easier.

05:47 I mean, I feel like kind of their mission now that they control like 90 percent of the Git surface out there on the Internet is to just make lives easier for the people that are using their products.

05:58 So I think that, you know, stuff like this, stuff like having just a simple notification that says, hey, this, you know, your upstream branches, you know, ahead of you.

06:07 Click here and we'll we'll get everything merged in.

06:10 And the less GitHub commands I have to try to put in to remember that I am going to mess up 100 percent of the time, the better.

06:17 Yeah, it's so close to having this built in, right?

06:20 You've got the button that says right now, sync this.

06:23 If it just had a checkbox or something and just keep doing that, if you when you see these changes, you know, like basically install this automatically for me.

06:31 That'd be fantastic.

06:32 Maybe when you fork it, right?

06:33 I want to fork it and I want it to stay up to date.

06:35 I guess probably the hesitation is certain things.

06:39 It requires certain behaviors.

06:40 For example, you shouldn't be making direct changes to the branch that you're syncing with because you might end up with merge conflicts.

06:48 You have to work on a separate branch.

06:49 And I don't know, it probably gets complicated, but I would love to see this more automatic.

06:52 Yeah, it's cool.

06:53 I'm trying to remember what the next topic was.

06:56 My memory is not that good.

06:57 What do you you know, don't you?

06:59 Yeah.

07:00 Memory usage.

07:01 So you actually have a talk about this, don't you, about memory?

07:04 I do.

07:05 I've spoken about it before, for sure.

07:07 Yeah.

07:07 But so this is a cool article by Itamar.

07:11 I think his name is Itamar.

07:12 Is that right?

07:12 Yeah.

07:13 Anyway, it's a nice, easy to follow discussion.

07:16 But there's a cool example he goes through where it's just, it's kind of a neat one liner to allocate three gigs of memory.

07:28 I didn't, you know, it's kind of a neat thing with NumPy.

07:31 I'm just allocating a byte array or three, like a 1024 by 1024 by 1024 by three matrix.

07:41 So some clever math there.

07:44 You get three gigs.

07:45 But it actually works.

07:47 And then he goes through and uses psutil to read the memory and figure out how much is there.

07:55 So I had to, I actually, I paused at this point when I was reading the article to go and find out what all this stuff does.

08:01 So it's the, when allocating the, like a ones array, you can, NumPy has a way to just pre-allocate a bunch of ones, which is neat.

08:10 And you give it a shape of what, what the vector shape is that you, you want it in.

08:15 But then also this process stuff, I, it said RSS and I'm used to RSS being really simple syndication.

08:21 So no, RSS is, what is it?

08:25 Resident set size, which is essentially translates to the, to the resident memory, which is essentially how much RAM you're using.

08:32 So anyway, how much RAM are you using?

08:34 And, and we're using three gigs, a little bit more.

08:37 And then, and then he does something that I, I was like surprised by, goes out and just opens a couple of browsers and windows.

08:45 And then it goes back and checks again.

08:47 And suddenly it's down.

08:48 It's like way down.

08:50 And I tried this and I can get it to go really far down.

08:53 And that's because your computer is, is managing memory and taking some stuff out of RAM and putting it on disk and saving it till later.

09:02 So there's, this is kind of a, it's using the memory, but it's not currently actively loaded as, as RAM.

09:09 Yeah.

09:09 Gotcha.

09:09 Uh-huh.

09:10 Okay.

09:10 So, goes through, he, basically, this is a little bit of a tutorial on how memory works with your computer and what the difference between allocated memory is and peak allocated memory and resident memory.

09:21 And the allocated and peak allocated is like the max that's allocated at the time.

09:26 And, it's kind of too much to go into in this conversation, but, it's a really interesting discussion.

09:33 And he also talks about how to measure these using what the PSU till for one.

09:37 And then also, for the peak allocated memory, he used a profiler called fill.

09:42 so it was, I thought I learned a lot in just a few minutes reading this.

09:47 So.

09:47 Yeah.

09:48 Very nice.

09:48 Yeah.

09:49 NMR is doing all sorts of cool stuff, stuff with, memory analysis and profilers and whatnot.

09:54 there's a surprise in here of if, if you fill it with ones, you actually get three gigs.

10:00 But if you do the same thing with zeros, you get like nothing.

10:04 So, Python and NumPy figure, it's just zeros.

10:08 We'll just, we'll just remember that there are zeros and until you actually do something with it, we won't allocate it.

10:14 Oh, it's like a lazy allocation or something.

10:16 Yeah.

10:17 Yeah.

10:17 Yeah.

10:18 Interesting.

10:18 Yeah.

10:19 So what I was going to say is another thing that's tricky is like, this is using psutil.process.memory to analyze it.

10:26 It's just what, how much memory is the process using, which is not always the right way to think about how much memory you're sort of demanding.

10:34 Because the allocation in Python, you know, you allocate in blocks, big blocks of memory, and then the blocks are managed in pools.

10:42 And then the pools are managed in arenas.

10:44 And there's a lot of pre-allocation and then reuse, but you end up with like over-allocation and then eventually filling those up with things.

10:51 And so it gets pretty interesting about actually understanding precisely how much memory and what's using it.

10:58 It's not quite as straightforward as just how much process memory is being used.

11:03 But that's still a decent proxy, right?

11:05 I just want to know how I can subscribe to that RSS feed.

11:08 I know.

11:11 I had the same thought when I saw it.

11:13 Well.

11:13 All right.

11:14 Jay, you got the next one.

11:15 What do we got here?

11:15 All right.

11:17 So this originally came from a video that I saw trying to solve a problem that I had.

11:22 And I had to do some deep searching to figure out whether or not we talked about it before, if y'all talked about it before.

11:28 But we all know f-strings now.

11:31 We love f-strings.

11:32 f-strings are awesome.

11:33 f-strings can do a lot.

11:36 Sometimes folks don't realize how much f-strings can do.

11:41 Like, for instance, did you know if you put an equal sign after a value, it will actually give you the variable that you've provided, equals, and then whatever the value is, which I think is awesome when it comes to logging and figuring out other information.

11:54 But one thing I did not know is that you could use f-strings to format date time objects just right in the F string.

12:04 So you don't have to do, you know, like, date time dot string F time or, you know, string F format or all that stuff.

12:11 You can just do F string, the date time variable, and then the F string format code that you would use to format it normally.

12:20 And that's over here in this, you know, if I just scroll down, you can see here where, in this example, they use just date time, date time now, and then now colon the format.

12:32 And I saw that and my mind was blown because that means I now have to go back through a bunch of code and remove all of the string format, like parsing and just throw it directly into the date time field.

12:45 I'm kidding.

12:47 I'll also just throw out there sometimes you want to have that stuff separated so that it can be used elsewhere and you don't have to constantly rewrite it.

12:55 But we now have another way to format our date times.

13:00 But sadly, it still probably sucks with dealing with time zones because date times are hard.

13:07 They are hard.

13:08 I think it's totally non-obvious that you can have variable colon some format string and an F string.

13:15 But it's really nice.

13:15 The one that I use the most is colon comma for digit grouping.

13:19 I'm like, here's, you know, two million such and such.

13:22 And I wanted to do two comma, you know, three digits, comma, three digits.

13:26 I knew that you could do something like that.

13:28 I didn't know that that was how you did it.

13:30 So thank you for adding that to my list of things you can do with f-strings.

13:35 Yeah.

13:35 And I know one that you've spoken about, Brian, is to do like the variable equals, which Jay alluded to, where it prints out the name of the variable equals the value of the variable.

13:47 Do you use that often?

13:48 I use it all the time because I'm a kind of a printf debugger kind of person.

13:53 Yeah.

13:54 Yeah.

13:54 Let's see some comments from the live stream.

13:56 Magnus.

13:56 Hey, Magnus.

13:58 F string is cool.

13:59 I find selecting between repr and string and F string is really useful.

14:04 It's very neat.

14:04 Dean.

14:06 Hey, Dean.

14:06 How can I keep from, keep the formatting as a variable?

14:09 That's a good question.

14:10 Why don't you just assign it as a variable?

14:12 Can you use it in the F string?

14:15 Probably.

14:17 Maybe you've got to call stir of the variable.

14:19 I don't know.

14:20 Oh, man.

14:20 Well, that's where you start getting the bang art, like the exclamation point R to like just force it to do a repr on whatever you provided.

14:30 Again, not saying that you should do it that way, but I mean, probably could.

14:36 Yeah.

14:36 Yeah.

14:37 Definitely.

14:38 And Sam out there in live streams says, how have I never heard of these?

14:41 Yes, I know.

14:42 It's amazing.

14:43 Amazing.

14:43 Amazing.

14:44 All right.

14:44 I want to throw in a quick thing I want to add to that really quick.

14:48 f-strings.

14:49 If you find yourself with a bunch of code that has been around for years, pre three, six, and you're like, ah, it's got who knows how many variations of formatting strings in it.

15:00 And you just want them all to be f-strings.

15:02 You can use Flint, F L Y N T.

15:05 Run that against the top level of your directory.

15:07 Boom.

15:08 Everything's f-strings.

15:09 It looks great.

15:10 I did this on like a 20,000 lines of Python code project.

15:13 It had one error.

15:14 I submitted it to them.

15:15 They fixed it.

15:16 And yeah, it was really neat.

15:18 That's cool.

15:19 Cool.

15:19 Cool.

15:20 Indeed.

15:20 All right.

15:21 What's the next one here?

15:23 I guess I got the next one.

15:24 Don't I, Brian?

15:24 Yeah.

15:25 Cool.

15:25 Well, this one, I went back a little bit back and forth on whether or not I actually wanted to feature this because it's a little bit recursive, I guess.

15:33 So I did a talk for Manning.

15:35 They had a developer productivity conference talk or a conference.

15:40 Jay, were you part of that?

15:41 I was not part.

15:42 I am hearing about this for the first time.

15:44 I feel like you should have been part of this.

15:46 I know.

15:46 How did you not get in here with your podcast and all?

15:48 So the conference was interesting.

15:52 There were some really neat talks.

15:54 There were some other talks that I'm not really sure abided by the theme of the conference.

15:58 They were just like, well, here's a random tech talk.

16:00 I was like, oh, okay.

16:00 Well, but that's not productivity.

16:02 Anyway, I tried to abide by the theme.

16:04 So I came up with a talk called 10 tips and tools you can adopt in 15 minutes or less to level up your developer productivity.

16:12 So really what I want to do is just give a quick shout out to like the 10 tips and people can go if they're really interested.

16:17 So they can seek around the video and go find that or email me and I'll send you the slides.

16:22 So one of them is to use a proper shell.

16:24 Like I find every now and then I run into people and they're just running, you know, the whatever comes out of terminal in macOS or they're just using cmd.exe on Windows.

16:34 And it's like, how can you go day to day?

16:36 Like there's so much possibility there, right?

16:39 So, you know, consider things like OhMyZShell or OhMyPosh.

16:43 I just installed OhMyPosh on the Windows terminal with the new PowerShell on Windows.

16:48 And that thing is so much nicer than what you had before.

16:51 That's cool.

16:52 So get a proper terminal with some of those options.

16:55 Use, if you're doing anything on the web, use secure.py, which just adds all the OWASP secure headers that you're supposed to do.

17:04 Like don't allow your site to be embedded in an iframe and cross-site scripting and stuff.

17:08 Automatically it supports like 10 different Python web frameworks.

17:11 And if you're on some other technology, there's things like inWebSec, which does the same thing for ASP.NET, or I'm sure you can Google another one.

17:18 Tip number three, pick a nice GUI for your Git work.

17:24 Sometimes it's fine to do stuff on the command shell or on the CLI, but it's really nice to have visual views of like branching and whatnot.

17:33 So think of like source tree or even PyCharm and VS Code.

17:36 Sync your GitHub forks.

17:37 Just talking about that.

17:38 So keeping that going.

17:39 Use a proper log framework like Loguru or even Sentry.

17:43 Use Let's Encrypt.

17:44 Number seven, you can go and just get your site map and request every URL at that destination.

17:52 And your site map.

17:53 And that's a way to just like make sure your site's not going to die.

17:56 So you could put that as an integration test.

17:58 Use PageSpeed Insights to make sure your SEO is good and your site's responding well.

18:03 Use Homebrew or Chocolaty on Windows.

18:05 And then the very last one is set up Dependabot or even some of the stuff that we talked about, Brian.

18:09 Start using pip compile with a .in file.

18:14 And you can tell it to upgrade the requirements whenever you run some CLI command.

18:19 And it'll regenerate your requirements.txt based on all the dependencies.

18:24 And it gives you a really nice organization like this subdependency is here because of these three things you've installed in your main requirements.in and so on.

18:34 Yeah.

18:34 There's 10 quick tips that people can go play with and they can check out that short video if they're interested.

18:39 I mean, I know 11 quick tips wouldn't have been, you know, an amazing brand.

18:45 But I feel like virtual environments, like not brought up at all.

18:49 That was.

18:50 Yeah, that's true.

18:51 That's a good point.

18:52 Yeah, I mean, you should have been in the conference, I'm pretty sure.

18:54 Oh, man.

18:56 Yeah.

18:56 Only had I known about it.

18:57 Do some people not use virtual environments?

19:00 Dean also has an 11.

19:03 They're maybe 12 now.

19:04 Close that Facebook tab.

19:05 Yeah.

19:06 I'm surprised at how many people don't use virtual environments still.

19:09 Or even I don't want to say something like using like Pipim or Poetry or anything like that.

19:15 Mostly just because I don't have a lot of experience with them.

19:18 But what is it?

19:20 Virtual environment wrapper or even Pyenv.

19:24 Yeah.

19:25 Just really great tools to make sure that everyone's operating on the same Python version.

19:30 And that, you know, if you need to run Python 3.5 on one thing because, you know, your code isn't set up for it yet.

19:38 And then you want to run 3.9 on something else.

19:40 Having tools like that, that once you learn them, they're so phenomenal and just so easy to use.

19:47 Yeah.

19:47 I wonder if the overlap of the people that have a Facebook tab up are the same people that don't use virtual environments.

19:53 Probably.

19:55 Probably.

19:57 Notifications as well.

19:58 Turn off notifications.

19:59 Like, don't let Outlook or other things like that, like send you, like, don't let your email send you messages.

20:04 They're like pot toast, right?

20:05 Turn on do not disturb.

20:07 Yeah.

20:07 Oh, before we move on, Dean mentions in the chat for the F-string thing, you can put, you can put layers of curly braces in there.

20:18 What? Like F-string within F-string?

20:20 No way.

20:21 Yeah.

20:22 I feel like we're reaching a dangerous point.

20:24 No, that's awesome.

20:25 That's so cool.

20:26 Love it.

20:27 So for people who are listening, I'm not seeing this.

20:30 Yeah, yeah.

20:31 So for people listening, you would normally have an F-string, you say F, quote, you know, curly bracket variable, close curly.

20:36 And with the format as a colon, so Dean is saying that if you put as the format string curly variable that contains the format curly,

20:44 so like curlies within curlies, that'll do it.

20:47 That's awesome.

20:47 Thanks.

20:47 I had no idea and I have no idea how you found that out, but that's good.

20:51 Yo, dog, I heard you like curly braces.

20:53 I love them.

20:55 Very cool.

20:56 Very cool.

20:56 All right.

20:57 Let's see.

20:58 Oh, I'm next.

20:59 Cool.

21:00 I want to cover a cool article from Vitor called How to Start a Production Ready Django Project.

21:09 And this is sort of just a fun project article because it's focused on Django, definitely.

21:15 But I think this is a lot of this advice is just a good idea for any web app or I guess it's mostly web app stuff.

21:23 But anyway, it's worth a look even if you're using some other framework.

21:28 He starts out just said at the beginning when you get started project, just start it out right.

21:34 So one of the things that I thought was neat was making sure that you set up a local environment, a test environment, and a production environment.

21:44 And the easiest and most important is the local environment so that new developers can get up really quickly and just start, clone, and go.

21:54 And I think that's really important to make sure that that's working well and easy.

21:58 And then almost as important, and I would say maybe more important, but is a test environment.

22:04 So if you're swapping out like a different database or something for your test, making sure that that's configured and set up so that the developers, when they're contributing, can easily run the tests before they submit code to you.

22:18 So that's really important.

22:20 And then the production environment and the setup for that, that is an interesting argument that that can be more complicated.

22:28 That can be a different thing because most of the people involved in the project aren't really going to run that.

22:33 It's just a handful of experienced developers.

22:35 I think that's cool.

22:36 So after setting up the environment sort of stuff, it covers making sure that you have Git or some other version control set up and use virtual environments.

22:45 There you go, Jay.

22:46 Make sure that you're doing virtual environments.

22:50 But then there's a section on requirements.txt files that I think is amazing.

22:55 Maybe everybody knew this already, but it hadn't occurred to me, is to have a directory instead of just a file and have several of them.

23:04 And the example has a base one, a test one, a local one, and a production one, and they can include each other.

23:11 So all of them include the base.

23:13 And local also includes text.

23:15 So whatever environment is, you can just install one of these, and it's the right one.

23:20 And all the project stuff is all in the base.

23:24 So everybody uses that.

23:25 It's a pretty cool idea.

23:27 I've never done that.

23:28 Have you done that?

23:29 Either of you used that sort of a model before?

23:31 Yeah.

23:32 No.

23:33 I'm terrible.

23:34 I just put everything in environment variables, and then I never have to change my code.

23:38 I just have to change my environment variables depending on what area of system I'm in.

23:43 Yeah.

23:43 So that discussion was around the requirements, but there's also a similar discussion around the settings.

23:50 So the settings set up to make sure that you've got where the database is, where your server is, and all that stuff, and have those set up for and switched for local test and production.

24:01 And just getting all of that stuff set up ahead of time right at the beginning of the project.

24:07 And included a couple of things I was surprised to see was making sure that you've got a consistent set of linting and styling tools like Black or Flake 8 or iSort.

24:18 And then also editor configurations.

24:21 It might make the whole team more productive if you just go ahead and store your editor configurations in the project.

24:28 I never considered doing that.

24:30 Yeah, one thing that's really cool is for PyCharm.

24:34 I don't know how VS Code works.

24:35 There's maybe something for it as well.

24:37 But in PyCharm, you can go and customize the code cleanup and formatting and rules of what it inspects and how it'll fix them.

24:44 And then instead of saying, save that in my user profile, you can say, save this in the PyCharm project.

24:50 So if other people on the team open it up, it won't show squigglies if your convention is different than Pep 8 or if you format it, it won't jump around and stuff.

24:59 That's cool.

25:00 And then, of course, there's some Django-specific stuff like application structure and stuff.

25:05 But I think, like I said, even if you're not using Django, this is a good set of things to look through.

25:09 Yeah.

25:09 Yeah, cool.

25:10 I guess I do the thing with the requirements, have like a dev version that's based on the production version and whatnot.

25:15 But with settings, I hadn't really thought about that.

25:18 That's cool.

25:19 Indeed.

25:19 Indeed, indeed.

25:20 Let's see.

25:21 Jay, you got the next one?

25:22 I do.

25:23 And just as I always try to bring some type of productivity app, tip or trick, this time it's a Mac app.

25:31 Sorry, folks in Windows land.

25:34 It's Mac only.

25:36 But I'm sure you could do something similar with like AutoHotKey or one of the similar tools.

25:41 But I'm talking about a program that a friend of mine, Brett Turfstrom, made called Bunch.

25:46 It is interesting in how simple yet complex it can get.

25:51 So those that don't know, I work on, I help Mike out from time to time, more specifically with the Talk Python newsletter.

26:01 And this is literally the Bunch that I run every time I start working on the newsletter.

26:08 So the thing about Bunch that's really cool is one, it uses FrontMatter to set up a bunch of different settings within the program.

26:16 So that's what you see at the top.

26:18 But now here's the title of the thing.

26:19 I want it to run sequentially, not parallel.

26:21 Well, and then if I want to open an app, I just type the name of the app.

26:26 If I want to open Windows within that app, I just add a dash and provide the URLs or the file names for those files.

26:34 If I want to run.

26:36 So you've got like Safari and then it has three nested things that are URLs.

26:40 So what it does is it opens Safari and then launches those three tabs.

26:43 Yep.

26:44 Perfect.

26:44 And I actually don't even have to tell it to run Safari.

26:48 I just kind of do here so people reading it can make sense of it.

26:52 If I just put three URLs on there, it would just open up whatever the default browser is and then open those files.

26:58 But by putting Safari in front, I tell it specifically open these in Safari.

27:02 So if you work with Chrome or if you want to do something like testing on multiple browsers, you could put, you know, each browser and then dash whatever the URL is for that.

27:12 But the thing I like about this is it also supports things like X callback URLs, which are kind of a URL structure for running commands in applications that support it.

27:24 You can add system commands and commands to bunch itself like throwing a pause in.

27:29 If I wanted to actually go in and type like at the end, whenever I finish the newsletter, I open up messages.

27:36 I hit command F, which is that at sign and F pause for a second because sometimes my Mac is slow.

27:43 And then I type in Michael Kennedy and hit enter.

27:46 And you can even do some conditional stuff.

27:49 Like I have an Apple script that just checks the date.

27:52 If it's in the date range that I need to to make sure that I send bills off properly, then it also will open up, you know, Stripe and let me do my processing thing.

28:02 But it supports shell scripts, which means it supports Python.

28:05 I actually do have a couple that I'm running.

28:09 Well, I haven't ran in a while, but it just opens up and it kind of does similar to what we were talking about in the first topic of like just going in and making sure that projects are up to date because I will forget the commands or I will mess them up.

28:22 And it's easier if I can just follow along with what it's doing.

28:25 And there's a lot of different tools here.

28:27 I don't have enough time to talk about all the things it can do.

28:30 One of Michael's tips that he left off setting do not disturb.

28:33 I could do that by just typing in parentheses D&D like that.

28:38 And it'll set do not disturb whenever this runs.

28:42 And you said something like this as a part of your Z, your profile shell setup.

28:49 So when you log in, it like kicks off one of these to sort of configure your environment the way you like it.

28:54 So that's for example, I like want to log in and I want the first hour to have no notification.

28:59 So I can just focus when I got energy in the morning and then like turn off D&D later or something like that.

29:04 So that's the cool thing with front matter is like you could just say start on.

29:08 And if, you know, if I start my day at 7 a.m., I just put start on 7 a.m.

29:13 And, you know, I would just create a second bunch that says, you know, start on whatever I wanted to end.

29:20 And then it would turn it off like D&D off.

29:22 I think you can actually even do like a close on.

29:24 So I could even say like close on like 8 a.m.

29:28 Like that.

29:28 And I don't know about that last one.

29:31 I have to test that.

29:32 But there's start at.

29:34 So you can have it run on certain days of the week.

29:36 There is not a way natively to have it run on a certain day of the month.

29:40 It doesn't have cron support.

29:41 But there is a workaround that I've highlighted in another video, which speaking of, I talk about this on my YouTube channel, which is YouTube.com slash KJ Miller.

29:51 My handle on everything that I do.

29:53 That's cool.

29:54 You got a nice YouTube video that walks through this, right?

29:56 People can check that out.

29:57 Yeah.

29:58 And I break down everything that's happening in this particular bunch.

30:01 Like even the Apple script, which is actually JavaScript, but it's fine.

30:06 I would have expected D&D to like send out Dungeons and Dragons invites to random people.

30:12 Well, funny enough, if you had a bunch called D&D, you could just do D&D.bunch like that and it would just run it.

30:19 So that is doable.

30:21 We can make that happen.

30:23 Yeah.

30:24 All right.

30:24 Everybody gets a Mountain Dew, order a pizza, show up.

30:27 How's this going to go?

30:28 Exactly.

30:29 By the way, Bunch is free.

30:31 If you go to bunchapp.co, you can just install it and run it for free.

30:35 Again, the developer, it's a solo developer, Brett Terpstra.

30:38 He makes other mad science on the internet.

30:41 And I believe he works for Oracle now just recently.

30:45 So yeah.

30:47 And then if you're an Alfred user, which I can't really, I don't have a good way of showing you what Alfred is.

30:52 But if you know, you know.

30:54 I am the maintainer.

30:56 It's probably the command space for Mac or the PowerShell, like little pop-up search in Windows.

31:02 Yeah.

31:03 But like as a dedicated app that does more, right?

31:05 Exactly.

31:06 And I am the maintainer of the Bunch workflow, like the official unofficial Bunch workflow for Alfred.

31:14 So if you ever need help with that, you know who to yell at.

31:17 That'd be me.

31:18 Fantastic.

31:19 Oh, that's a cool one.

31:20 A nice find there.

31:21 Cool.

31:21 All right, Brian.

31:22 Is that it for us?

31:23 Our main items?

31:24 It's up.

31:25 That's up for our main items.

31:26 Do we have anything extra?

31:27 I was thinking no, and then actually yes.

31:30 So I just ran across this.

31:33 We talked about GitHub Copilot.

31:35 In fact, that was the title of last week.

31:37 Yeah.

31:38 It was like GitHub, your pilot speaking or something like that.

31:41 And how both mind-blowing and like good and possibly kind of crazy, not necessarily good ways that the Copilot was.

31:49 And it was pretty interesting, right?

31:50 Yeah.

31:51 So there's an article over on The Verge, and I had pointed out, like, what is the license?

31:57 What is the transitive license here?

31:59 What's the, if you have a GPL license and then you filter it through ML, is the transitive property applied to the GPL, basically was my question, right?

32:09 And so there's an article over on The Verge that says, GitHub's automatic coding tool, aka GitHub Copilot, rests on untested legal ground.

32:18 So there's one section in here that says, despite GitHub's assertion, there's no direct legal precedent in the United States that upholds publicly available training data as fair use.

32:30 So anyway, if people are interested in this, they can check it out.

32:33 I think there's also a caveat there, too, of what GitHub is doing is on untested ground, and your usage of what GitHub is doing is also on untested ground.

32:45 Not saying that you can or can't use this, but just know that even if GitHub, you know, wins a lawsuit saying that they're good, you may not want to be the person to have to test the lawsuit of whether or not you're going to be good.

33:01 So, and again, I'm not a lawyer, so I don't even pretend to be one.

33:05 Yeah.

33:06 I think it's a cool project, though.

33:08 Yeah.

33:09 It is quite cool.

33:10 It's quite cool.

33:11 All right.

33:11 Dean, I always appreciate the help in the comments.

33:14 So time for some extra, extra, extra, extra, extra.

33:17 This time, actually, no, I almost had no extras at all.

33:19 I was feeling bad.

33:20 But just the one.

33:21 Yeah.

33:23 Okay.

33:24 So I wanted to share something exciting.

33:25 So.

33:26 Also, one more thing.

33:27 I don't know if I clicked this or you clicked it.

33:29 But Magnus says, I also saw that Copilot spouted API keys.

33:33 So we've heard of Shugit and other Don't Put Secrets in here.

33:36 But here's yet another interesting way.

33:38 You want to connect to AWS?

33:39 Here.

33:40 Here's the API key.

33:41 Here's the API key.

33:42 That's awesome.

33:44 Go ahead and try it.

33:45 Why not?

33:45 You don't know who's paying for that.

33:46 It's free.

33:48 It's free for you.

33:49 Yeah.

33:49 So I'm continuing to work on the pytest book.

33:52 I just got the configuration chapter turned in.

33:56 It's not available in the beta yet.

33:58 But it will be within the next few days.

34:00 So configuration stuff.

34:01 It's all fun.

34:02 And then I'm excited to get working.

34:05 The next chapters, I'm going to start working on our talks and CI.

34:08 And the search path and debugging.

34:09 And those will be fun chapters.

34:11 So I just wanted to share where I'm at there.

34:13 Awesome.

34:14 You're almost there.

34:15 Yeah.

34:16 And then I had an extra too.

34:18 But it's so silly.

34:20 But it's just fun.

34:21 I have to stop sharing that.

34:22 And I have to share another window now.

34:24 Thanks.

34:24 Thanks, Streamy.

34:25 Thanks for that.

34:26 But I found a new tool to play with.

34:28 It's called Monodraw.

34:31 Which is a very, very interesting tool.

34:35 I don't know what most people would use it for.

34:38 But I've been using it as an outline and planning tool.

34:42 And I'm going to show you what I do with it.

34:44 I'm going to add a text here.

34:46 And it's going to say, I Python Bytes Crew.

34:49 And I'm going to hit Done.

34:51 So for people listening, this is like kind of drawing on graph paper.

34:55 Yeah.

34:55 Yeah.

34:56 Okay.

34:56 So what happens if I expand this out and I tell it I want it to be a banner?

35:04 Oh, that's pretty fun.

35:05 That was fun to be digital.

35:07 It turned it into like ASCII art and stuff.

35:10 Yeah.

35:11 So this is a way to actually build like ASCII art outlines.

35:17 And they have a bunch of different versions.

35:19 And I mean, I've used this on a couple of projects.

35:23 I'm trying to see if I have one that I can load up real quick for like a video that I've made.

35:28 And when I say it doesn't make sense why this works for my brain, like it truly doesn't.

35:35 But when it comes to, oh, did it, did it not move it to the, it didn't move it to the right window.

35:40 Hold on.

35:41 Thanks again, StreamYard.

35:42 Okay.

35:43 I want to use this for my next status report and just do the entire status report in ASCII art.

35:49 Yes.

35:50 So funny you mentioned that.

35:51 Put it as a comment and check it in.

35:52 Funny you mentioned that because when I do my video planning, I do it in this format.

35:59 And it's great because you can, you know, you can move stuff around, you can draw arrows, you can highlight different sections and, you know, know how everything is going to look there.

36:09 And when I, when I say like, I was able to, in a normal time, it would take for me to do a video.

36:15 I like cut that time in half by just drawing an outline out, using the different ASCII art to, to make things work.

36:22 I'm going to, I'm going to build like presentations with this.

36:25 I don't know.

36:25 I'm going to like give a conference talk using ASCII art one day.

36:29 Cool.

36:29 You could write a book like this.

36:30 You can copy and paste, but you can also export it as a PDF.

36:35 Let me see what options they have here.

36:37 You can export as PDF, scalable vector graphics, or, I'm sorry, ping, text, or SVG.

36:45 Those three.

36:46 For some reason, I thought there was a PDF version in there, but there is not.

36:49 Cool.

36:50 Sean out there was asking if you could export the art.

36:54 And hey, Sean, co-host of the Teaching Python podcast.

36:58 And I guess the thing is, it is $5.

37:02 And I have a link in the show notes for it as well.

37:06 But really fun tool.

37:07 I haven't figured out all of my use cases for it, but I know that creating outlines and stuff

37:11 has definitely been a very interesting and effective way of using it.

37:17 And it's called Monodraw.

37:18 And again, it's a Mac-only app.

37:19 I'm sorry, Windows folks.

37:20 But I'm sure that there's something out there.

37:23 And if not, build it.

37:24 Yeah.

37:24 Or get one of those weird macOS in the cloud as a service.

37:28 That's true.

37:30 That one was Mac-only to my knowledge.

37:33 Yeah.

37:34 Yeah.

37:35 All right.

37:36 I'm on a joke.

37:37 Yeah.

37:38 I think it's time for a joke.

37:38 Okay.

37:39 So imagine that we're here meeting for a startup and we're trying to figure out, we're going

37:45 to create some new API here and we're having a bit of trouble.

37:50 So let's see.

37:52 So this is like a little bit of a comic strip.

37:54 And I guess, Jay, you want to be the person at the computer?

37:56 I'll be the bearded dude.

37:57 And Brian, you can be the guy with the glasses.

37:59 Other guy with glasses.

38:00 All right.

38:02 Dude, they're trying to think of what to name this API, right?

38:05 Or this thing.

38:06 So data?

38:07 Nah, too generic.

38:09 How about data DB?

38:10 Unclear.

38:11 Well, let's say list completed.

38:14 Already used that.

38:16 Array list data completed then?

38:19 Nah.

38:20 We must choose now or the client might cancel the project.

38:24 Well, how about array list completed from form without duplicate?

38:31 Nah, it's too long.

38:32 And then the next panel has like a newspaper clipping that says unable to name variable,

38:38 they go bust.

38:39 Yeah, exactly.

38:40 Go out of business.

38:41 They couldn't choose naming.

38:42 That is one of the hard problems of computer science, right?

38:44 Is naming.

38:45 Yeah.

38:45 Yeah, definitely.

38:46 I didn't see completed form or completed form without duplicates.

38:52 Like that's what I see.

38:55 It's almost like the array list, which I mean, if you're making good, good, like readable

39:01 code, you would know that it's an array list.

39:03 So I would say, yeah.

39:04 You don't need this like type name.

39:06 Do completed form without duplicate.

39:07 Yeah.

39:07 Well, you would have saved them.

39:09 They'd still be in business.

39:10 Or unique.

39:12 Unique.

39:12 Like completed unique.

39:15 Just everybody.

39:16 Just use foo, bar, and baz, and then nobody will complain.

39:19 So do you remember those like those Microsoft-isms where they would like prefix types, variables

39:28 with their type names?

39:29 The Hungarian notation like SZ for string.

39:33 What the heck was the Z there for?

39:34 Size.

39:35 SZ for size.

39:36 Size.

39:36 Size.

39:36 Size.

39:37 That's right.

39:37 Yeah.

39:37 Oh my gosh.

39:38 That was dreadful.

39:39 Terrible.

39:39 Yeah.

39:40 With like three characters left over for the actual variable name.

39:43 Anyway.

39:45 Cool.

39:45 Well, this was fun.

39:46 Thanks, Jay, for showing up today.

39:48 And thanks, Michael, as always.

39:49 Yeah.

39:50 You bet.

39:50 Bye, you guys.

39:51 Thanks so much for listening.

Back to show page