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


Transcript #390: Coding in a Castle

Return to episode page view on github
Recorded on Tuesday, Jul 2, 2024.

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

00:05 This is episode 390, recorded July 2nd, 2024.

00:11 I'm Michael Kennedy.

00:12 And I'm Brian Okken.

00:13 And this episode is brought to you by Scout APM.

00:17 Thank you so much to them for supporting the show.

00:19 We really appreciate them.

00:20 And if you want to attend live, get your comments in the episode, then check out pythonbytes.fm/live.

00:28 Usually Tuesday at 10 a.m. Pacific time, like we're recording right now, Brian.

00:33 Yeah.

00:33 And please visit Python Bytes, Ed FM, right on the homepage, click on newsletter, subscribe to our newsletter.

00:40 We've got lots of interesting information that we share with you.

00:43 And we're going to be doing some kind of giveaway that we have yet to determine.

00:47 And soon when we reach maybe a major milestone there.

00:51 So that'll be awesome.

00:52 Yeah.

00:52 And yeah, with that, Brian, you want to kick us off?

00:56 Sure.

00:57 What do you got for us?

00:57 Let's talk about strings for a minute.

00:59 So this one is from an article written by Veronica Olson.

01:04 And it's an article called Joining Strings in Python Aha Moment.

01:10 And I actually just really enjoyed this story because it's a it tricked me up.

01:15 And she says, I've been writing Python code for 17 years.

01:20 And then I learned something new recently from a master on conversation.

01:25 So what is the new thing?

01:27 So the idea is around joining strings.

01:31 So let's say you're like, and we do this, I do this all the time.

01:36 So you've got some input from a file.

01:38 And her example is, you've got some input from a file.

01:41 And you're going through and just using it, using the regenerator thing.

01:46 So f equals open.

01:47 And you get like this thing that you can read with.

01:49 So she's using x for x, or I usually put line.

01:54 Line for line in f.

01:55 And then also doing like some logic on it within a generator, which is kind of cool.

02:01 And once I learned this, I use it all the time.

02:04 So go through using the file as a generator to pull out lines and then only collect the lines that you care about.

02:11 And then joining it in at the end.

02:13 And so like this discussion really is when you've got a whole bunch of strings that you want to concatenate together with like new lines or something.

02:21 You just create a list of them and then join it.

02:25 But if you're using a generator, you can use a generator and pass that to join also.

02:30 So the little trick here is whether or not you should use a list comprehension.

02:36 So these two methods is you're joining a generator out of the file or you use a list comprehension within it.

02:45 And the only difference is these little brackets in there to create a generator or to create a list comprehension.

02:53 So I would think my first reaction is that it really probably doesn't matter.

02:59 But the list comprehension might be maybe I have no idea which one's slower or faster.

03:05 But the odd thing is, if it's a huge text file, Brian, if it's a huge text file, it could be a memory.

03:11 If you had a gig of text, right?

03:14 Yeah.

03:14 Then you potentially would be loading more than that in memory with the brackets, but not with the parentheses, right?

03:20 That's what I thought.

03:22 Right.

03:22 So she used a sample file like the King James version of the Bible or something.

03:30 Yeah.

03:30 Yeah.

03:30 Yeah.

03:30 Which is 800,000 words long and a ballpark of 3,000 pages.

03:38 Anyway, 200 million words.

03:41 Okay.

03:42 So did a little timing here as to whether or not you want to use a generator or a list comprehension for this.

03:50 And looking at the memory output so that the memory itself is as expected.

03:56 The generator uses less memory.

03:57 The list comprehension gradually grows and you're using more memory.

04:01 Okay.

04:02 So far, it seems like it's doing what we think it might be doing.

04:06 But the weird bit is when we go down and actually time this stuff is that the generator version without it.

04:16 And if you compare the times for the generator and the list comprehension, the generator one is slower by like 16%.

04:24 Weird.

04:25 Why?

04:25 That is weird.

04:27 Especially since the list has to like, you allocate the list, you fill the list, you reallocate the list, you copied over, like growing the list over and over and over.

04:36 Although as a list comprehension, maybe it doesn't.

04:39 I don't know.

04:40 Anyway, that's crazy.

04:41 And then adding more mystery to the mystery is that instead of join, if you use all as the thing that you're using across the entire list or generator,

04:55 it's behaving as expected, the generator is faster than the comprehension.

05:00 So what's going on?

05:01 So the discussion went online and Trey Hunter said, you should know something about join.

05:08 Join is weird in that the CPython implementation of join is a two-pass because generators can, you can't, they get exhausted and you can't use them again.

05:20 So it has some little tricks that it uses to do a two-pass over the generator.

05:25 And so therefore it is, it is the same.

05:29 The join is the same as take creating a list.

05:33 And we know that comprehensions are a little bit better than actually just creating a list.

05:38 So that little bit better is the reason why the comprehension version is faster.

05:44 Well, wait, I have no idea why.

05:46 I should have read more closely.

05:48 But there's something about this that makes it faster in when you're using joins to go ahead and use a comprehension faster.

05:55 Interesting.

05:57 And it's only in CPython.

06:00 Apparently that's not true for PyPy and, yeah, apparently you can, I don't know how they're doing it without it.

06:09 But PyPy and some others implementations of Python do not use this.

06:14 But anyway.

06:15 Interesting.

06:16 Yeah, I don't see it tested here, but the WebAssembly one would be quite interesting.

06:22 Yeah.

06:22 For PyDyde and PyScript and those kinds of things.

06:26 Definitely.

06:26 Okay.

06:28 So interesting inside baseball around, I guess, around if you want to do memory, whether you care about speed or memory efficiency.

06:35 And also.

06:37 It's weird that you got to choose though.

06:39 It is weird that you have to choose.

06:41 But also just in case you haven't seen this, this is basically the standard format for if you want to iterate through strings and combine them all into one.

06:50 Is to either throw them in a list or throw them in a comprehension or throw them in a generator and use join to combine them with a new line.

06:58 If you haven't seen that before, that's a good thing to stick in your tool belt.

07:01 Yeah.

07:01 And our Windows friends can put backslash or backslash in join for their Windows line.

07:06 Didn't he?

07:06 I'm on Windows.

07:07 I don't do that.

07:08 But okay.

07:09 I know.

07:09 It should still work.

07:11 All right.

07:13 Awesome.

07:14 Well, what do you have for us next?

07:15 Well, I'm afraid I have some hard truths for you, Brian.

07:18 Just like you've learned, it's a hard truth that generator doesn't always give you the advantages you thought.

07:23 These are hard truth, 10 hard truths to swallow that people won't tell you about your brand new software engineering job.

07:30 So this is focused at students who just recently graduated or who are getting into software development.

07:35 And that might sound like a somewhat niche crowd, but if you look at the PSF JetBrains survey, it's like the biggest group of people are like, well, you've been coding for three years or less, which is crazy.

07:48 All right.

07:48 Anyway, let's go through the 10.

07:50 This is by Mansour Durevich.

07:52 Pretty good.

07:53 A pretty good article here.

07:55 And basically says, I was talking with a bunch of students and they were all psyched about like startup culture, pizza parties and stuff.

08:01 Well, yes, but the thing you're going to do most of the time, write code.

08:05 So here are the 10.

08:07 First, college will not prepare you for the job.

08:10 So imagine your instructor spends, you go to college to learn how to swim.

08:14 Your instructor spends a lot of time teaching you about the moves, reciting the moves, asking you questions about the moves.

08:21 After five years, you get a piece of paper that proves your swimming skills.

08:25 And then you got to go in the pool and you just flail around, right?

08:27 A little bit like that.

08:29 Also, a lot of the curriculums are pretty far behind.

08:33 I remember when I was in college, I said, can I please take C++?

08:37 It's in the 90s.

08:38 They're like, no, you have to take Fortran.

08:40 It's the most important language you'll ever learn.

08:42 I'm like, okay, and then I'm like, well, let me try some CS classes.

08:45 Like, well, you got to do Lisp.

08:46 Like, really?

08:47 Can I please take something like more modern?

08:50 Like, no.

08:51 So you should have embraced the Lisp.

08:53 Yeah, I'm still not embracing the Lisp.

08:55 I like parentheses, but not that much.

08:58 Okay.

08:58 Anyway, so a lot of these folks who are professors have not been professional software developers in the engineering sense.

09:05 And so the skills that they teach you are valuable, but it's not the same as like working day to day.

09:11 This one, I think, is probably, people probably don't realize that much, is you rarely get to work on greenfield projects.

09:18 Yeah.

09:18 You get brownfield projects.

09:20 That is, you get some project that is not a three-week project, but it's something that's been around since 2003.

09:27 And you're dropped in to work on some features.

09:29 And every time you poke it, it's like a rickety house of cards.

09:33 You got to be super careful.

09:34 Right?

09:35 How does that fit with your understanding?

09:37 Yeah, definitely true.

09:38 That's one of the reasons why I encourage people to contribute to open source projects, even in large ones, because you have to get used to huge code bases.

09:49 You have to get used to getting thrown in the deep end and fix a bug, and you don't even know what the code does.

09:54 Yeah, this is essential.

09:57 Speaking of which, there's a fantastic picture for this.

09:59 So let me try to zoom that out for a second so we can see here, Brian.

10:03 So check this link out, folks.

10:05 So there's, it's like this crazy Rube Goldbergian thing.

10:08 There's a button to start the app, and it's got all these weird wires.

10:12 And there's like an elephant that's suspended, and the wire cuts the elephant loose, which drops off a rock.

10:18 And there's a security layer.

10:19 There's the core logic since 2003.

10:22 There's all these, like, third-party bits that are largely controlled by aliens.

10:28 And then there's a cloud.

10:29 And below the cloud, you can see just the base of the building.

10:32 There's two new engineers with a little button that's supposed to, like, kick this thing off or something.

10:37 It says, how hard can it be?

10:38 Come on.

10:38 Yeah.

10:39 Yeah, amazing.

10:41 So check that out.

10:42 All right.

10:42 Coming back.

10:44 Nobody gives a blankety-blank about your clean code.

10:47 You may focus on it a lot, but really, your job is to deliver features.

10:51 You're expected to write clean code, but you're not going to get, like, promotions and stuff from the business people because you write clean code.

10:58 It's because you deliver value, right?

11:00 Part of that value is clean code.

11:02 That's true, but you've got to maintain it, too.

11:04 So you should be happy with it.

11:05 Yes, you've got to live with it.

11:06 So here's my experience.

11:09 Not how do you lie, but how do you phrase things?

11:12 Like, estimates and stuff so that you're in a position so you don't have to write terrible code constantly.

11:18 Right?

11:19 So, for example, with testing or a little bit of refactoring, it's just like I would just work that into my estimates.

11:25 How long is it going to take?

11:25 It's going to take a week.

11:26 Well, it probably takes three and a half days, but then if you were to bust it out, right?

11:30 But if you're going to put in the test and do it right, it'll take a week.

11:33 So how long does it take?

11:34 It takes a week.

11:35 You know, that kind of thing.

11:36 Sometimes you'll work with incompetent people.

11:38 Oh, boy, oh, boy, oh, boy.

11:40 Yes.

11:41 And sometimes that person will be your boss.

11:43 And so.

11:44 That's even tougher.

11:45 I'll tell you a story, Brian.

11:47 You know, I used to do in-person training classes.

11:49 And there was a person who was in this class as part of a team, software development team from a medium-sized company.

11:58 One of these, like, you know, 50 million yearly revenue type companies or something.

12:02 And during that class, we were doing, like, exercises.

12:05 I'd do a presentation for an hour.

12:07 They'd spend maybe half an hour working on something.

12:09 And round and round, it goes.

12:10 So there's this part where you need a variable that has a string value.

12:15 This person has been working for at least six months, I think a lot longer, as a professional software developer in this language.

12:21 And I say, okay, you've got to create a variable there.

12:23 And you need to assign a string to it that says, you know, XYZ.

12:28 The value of the string is XYZ.

12:30 So they just write variable name equals XYZ with spaces and all sorts of stuff.

12:34 Like, no, you can't just type it into the editor.

12:37 You have to put quotes around it.

12:38 What do you mean?

12:39 You have to put quotes around this.

12:41 Like, how have you been a professional software developer at a proper company for over six months to a year and not know that sentences with spaces?

12:51 They have quotes around them to put them into code as a piece of text.

12:55 Like, could you imagine that person just like reviewing your code?

12:58 Like, oh my goodness, dude.

13:00 Yeah.

13:01 No.

13:01 That was a rough one.

13:04 Anyway, sometimes, maybe not to that extreme, but you will probably end up working with ineffective people.

13:08 Or people that don't care about your process.

13:10 Or people that don't care about your clean code or whatever, right?

13:12 All that stuff's there.

13:13 Get used to being, number five, get used to being in meetings for hours.

13:17 This is an important part of software development job.

13:20 Most meetings are not productive because you're being forced to be there by a person whose only job is to have meetings.

13:27 That's their job.

13:29 That's their work.

13:29 Right?

13:30 Which is, ugh.

13:31 However, other meetings with your team members and stuff, planning out code and whatnot is pretty good.

13:37 Yeah.

13:37 If you're the one responsible for the meeting, be okay with cutting it short.

13:41 Getting everybody together and leaving in 10 minutes is fine.

13:44 Remember that.

13:45 Yep.

13:45 Okay.

13:46 A hundred percent.

13:47 Okay.

13:47 On.

13:48 I feel like you should have done this article.

13:50 No, I'll be the heckler in the background.

13:52 It's fine.

13:52 It's good.

13:53 They will ask you for estimates a lot of times.

13:55 I told you about this one.

13:57 I mentioned this.

13:57 This is fun.

13:58 So here's a great cartoon for this one, too.

14:01 This is also a good, like, basically the joke segment.

14:04 It says, would you rather?

14:05 For better estimates, we switched from measuring story points to a different style.

14:12 We now ask, how many duck-sized horses are you willing to fight rather than implement this task?

14:18 Isn't that awesome?

14:20 Yeah.

14:21 Yeah.

14:23 And it sounds silly, but I kind of think of it as it's actually kind of practical.

14:27 Yeah.

14:28 It's using your, like, your desire to avoid negative stimuli more than your ability to predict something.

14:35 I love it.

14:36 That one is only a two duck-sized horse battle.

14:40 All right.

14:41 Bugs will be your arch enemy for life because they come from different places.

14:44 Could be your own code, but it could be third-party libraries.

14:47 It could be hardware failure, electricity, all sorts of things.

14:50 Uncertainty will be your toxic friend.

14:53 So it could be implementing something you never worked on.

14:56 It could be getting transferred to a new project with new technologies.

15:00 It could be a move to a new company.

15:01 It could be a bug report the day you need to finish the work.

15:05 You're going to break the deadline.

15:06 Job security, evolution technology, all these things totally resonate.

15:10 Number nine, it will be almost impossible to disconnect from your job.

15:14 So, yeah, that's rough.

15:16 But it's true because you're thinking about it, right?

15:19 Yeah.

15:19 However, a lot of these come with actually good advice on what to do to combat it or to counteract it or to deal with it.

15:26 Oh, that's good.

15:26 Because one of the best things I ever did was not – I don't have the ability to get email on my phone now, my work email.

15:33 Oh, that's nice.

15:34 Because I was checking it all the time, even when I was off work, and that was bad.

15:40 Yeah, that's bad.

15:41 Last one, number 10, you will profit more from your soft skills than your coding skills.

15:48 Not that your coding skills are important, but – Yeah, definitely.

15:51 Soft skills are tough, and they're also required.

15:54 So, things like teamwork, learning mindset, time management, emotional intelligence and empathy, approachability, persistence, confidence, all these things amongst a whole zillion others.

16:04 Anyway, if you're new, I think this is a pretty good article.

16:07 I didn't go through all the little details, but – Yeah.

16:10 I don't know.

16:11 I don't know.

16:12 What do you think, Brian?

16:12 I think the soft skills probably ought to have been at the top.

16:17 Being able to communicate well and stay positive and don't be a jerk is huge.

16:24 The ability to not be a jerk under pressure, that was a struggle for me.

16:29 Also, embracing deadlines.

16:31 People are going to ask you how long it's going to take.

16:34 You just have to learn how to do that.

16:37 Estimating is part of the job.

16:38 It sucks.

16:39 It's wrong, but you get better at it, and you're also okay about telling it.

16:44 I mean, it can be ballparks.

16:46 It's going to be – is it going to be two days, or is it going to be two months?

16:49 Pick.

16:50 People just need to know.

16:52 So, yeah.

16:53 Yeah, absolutely.

16:54 It's good.

16:54 All right.

16:55 Before we move on to the next one, let's talk about a sponsor that I'm very excited about.

16:59 Let me tell you real quick about Gout APM.

17:03 They're big supporters of Python Bytes, so we appreciate that very much.

17:07 So, if you are tired of spending hours trying to find the root cause of issues impacting your performance, then you owe it to yourself to check out Scout APM.

17:15 They're a leading Python application performance monitoring tool, APM, that helps you identify and solve performance abnormalities faster and easier.

17:25 Scout APM ties bottlenecks such as memory leaks, slow database queries, background jobs, and the dreaded N plus one queries that you can end up if you do lazy loading in your ORM.

17:36 And then you say, oh, no, why is it so slow?

17:38 Why are you doing 200 database queries for what should be one?

17:40 So, you can find out things like that.

17:42 And it links it back directly to source code so you can spend less time in the debugger and healing logs and just finding the problems and moving on.

17:49 And you'll love it because it's built for developers by developers.

17:52 It makes it easy to get set up.

17:54 Seriously, you can do it in less than four minutes.

17:56 So, that's awesome.

17:57 And the best part is the pricing is straightforward.

18:00 You only pay for the data that you use with no hidden overage fees or per seat pricing.

18:06 And I just learned this, Brian.

18:08 They also have, they provide the pro version for free to all open source projects.

18:13 So, if you're an open source maintainer and you want to have Scout APM for that project, just shoot them a message or something on their pricing page about that.

18:21 So, you can start your free trial and get instant insights today.

18:25 Visit pythonbytes.fm/scout.

18:27 The link is in your podcast player show notes as well.

18:29 And please use that link.

18:31 Don't just search for them because otherwise they don't think you came from us.

18:35 And then they'd stop supporting the show.

18:36 So, please use our link pythonbytes.fm/scout.

18:39 Check them out.

18:40 It really supports the show.

18:42 Cool.

18:42 Yes.

18:43 Thank you indeed.

18:44 Over to you, Brian.

18:44 Well, we've talked in the past about Python coming to Excel, but I haven't tried it.

18:51 So, I was kind of curious about this person that wrote up an article called My Thoughts on Python in Excel.

18:57 And this isn't just a rando person.

19:00 Apparently, this is, let's see, or maybe, I don't know.

19:06 They wrote a book on Python in Excel or reported, yeah.

19:10 Or the creator of Excel Wings, maybe?

19:12 Yeah.

19:13 I'm not sure.

19:13 Oh, yeah.

19:14 As a creator of Excel Wings, the author of the O'Reilly book, Python for Excel, I was obviously curious to try it.

19:20 So, anyway, yeah, okay.

19:23 Anyway, so somebody tried it out.

19:25 Great.

19:26 And this is from the Excel Wings blog.

19:29 So, yeah, it's probably somebody that's worthwhile looking at this and tried, actually really wanted it to work.

19:35 So, what are their takeaways?

19:38 And I'm just kind of loving this.

19:40 We'll just run through them.

19:42 We wanted it to be an alternative to VBA, but mostly got an alternative to the Excel formula language.

19:49 Okay.

19:49 So, I thought it was going to be a VBA replacement as well.

19:53 Apparently not.

19:54 The integrating the Jupyter notebook cells inside Excel grid was a mistake.

19:59 So, not sure what they did there, but apparently they didn't like that.

20:03 So, Python in Excel is not suitable for Python beginners nor for interactive data analysis.

20:11 That's kind of, that's a bummer.

20:13 So, there's that one person left.

20:16 Yeah.

20:18 Right now, there are too many restrictions.

20:20 You can't use your own packages.

20:22 You can't connect to the web APIs.

20:23 So, what are the current use cases?

20:26 Probably computationally intensive things like Monte Carlo simulations.

20:31 AI stuff via the included packages like scikit-learn, NLTK, stats model, imbalance-learn.

20:40 That, actually, that makes sense.

20:42 And so, there's a, that's a good use case, I guess, for being able to use AI scikit-learn stuff in Excel.

20:50 Nice.

20:50 Being able to use Matplotlib and Seaborn for visualizations.

20:55 That's pretty cool because these are great packages.

20:57 Time series analysis.

21:00 And, but that's really about it.

21:01 Said, not sure about data cleaning or data analysis since you're mostly certain, almost certainly need power query.

21:08 I don't know what this is.

21:09 Must be an Excel thing.

21:11 It's like a BI Microsoft Office Tableau type of thing, I believe.

21:16 Okay.

21:17 So, what's the conclusion here?

21:20 Before we dive into details, I want to clarify that this is my personal opinion and not meant to be a rant or critique, but I'm amused by it.

21:28 I've been in contact with the Excel team a few times and they're super friendly.

21:32 Okay.

21:33 So, he wants the whole thing to succeed.

21:35 So, we'll just, that's good.

21:36 So, these are just interesting takeaways.

21:39 One of the things, and then goes through a bunch of the little bits, and in more detail, the part that wasn't in the summary, which I find is interesting, is Python is not really in Excel.

21:52 It's in the cloud, which I'm surprised by.

21:55 So, as you've probably heard, but I hadn't, that the Python that you're running runs in an Azure container instance, not inside Excel.

22:04 That's just kind of weird, I think.

22:06 Did you know this?

22:07 Yeah, I did.

22:09 And it's interesting that it means that you can't configure the environment.

22:12 You can't control which Python is running.

22:14 You can't install third-party packages that are not pre-approved, like you saw that there was a list of a couple of ML ones.

22:22 If you don't like those, then you don't use it.

22:24 Well, can you do it when your laptop's disconnected, like when you're on an airplane or something?

22:29 No, I don't think so.

22:30 Okay.

22:31 You know, just like quick, to me, I was hoping for like some kind of VBA, like true automation.

22:38 Yeah.

22:39 Sort of beyond the cell, this cell, that cell.

22:41 But kind of what you do with notebooks, and then sometimes you bring in like Excel writer or something to like actually save the stuff out or something, right?

22:50 Like a little way to orchestrate bigger.

22:52 Okay.

22:53 But yeah.

22:53 So it's just different.

22:56 It's just like stuff within a cell?

22:58 Well, multiple cells, but yes.

23:00 Okay.

23:01 Well, it's not really what I was hoping for, for Python and Excel.

23:04 So anyway.

23:06 Yeah.

23:06 It's also not quite in it, right?

23:07 Say that again?

23:08 It's not quite in it.

23:10 As I said, it's in the cloud.

23:11 Yeah.

23:12 It is weird that it's got to be online only.

23:14 Yeah.

23:15 That's kind of a deal breaker for me, but maybe I shouldn't care that much.

23:19 But anyway.

23:20 Yeah.

23:21 But one of the comments around that was that it's not really a problem for a lot of people because a lot of people that are using Excel are already sharing their data through OneDrive and SharePoint.

23:33 And I don't know if that's, maybe that's a majority of corporations, but there's a lot of corporations like the one I'm in where we cannot do that because we don't want our stuff to go out anywhere.

23:43 So anyway.

23:44 Yep.

23:44 Just an interesting takeaway of, I guess, if you've been hoping and thinking, this might be a good article to peruse just to make sure that it's really your use case before you jump in.

23:55 Yeah.

23:55 Good point.

23:56 Christopher out there says, it's nice that it doesn't require Python to be installed locally, unlike Power BI.

24:02 because I wouldn't be able to have my IT department install it.

24:06 So that's an interesting bonus there.

24:08 And Avaro says, you got to fight for your right to sudo.

24:14 There you go.

24:16 Can't you, I mean, Python now, can't you install it on Windows machines?

24:20 I think you can install it in like personal mode that's just in your home directory or something.

24:24 I don't think you need like administrator privileges anymore.

24:29 Yeah, that's true with the, it's actually true.

24:32 With the Python in the Windows store and Windows 10 and 11.

24:35 Yeah.

24:36 Yeah.

24:36 Okay.

24:37 Henry Schreiner on the audience.

24:39 Henry says, this feels like the perfect use case for WASM.

24:42 Sad it wasn't the default.

24:43 Totally agree.

24:44 Some pyodide here would have been awesome.

24:46 Yeah.

24:46 All right.

24:48 Um.

24:48 Not as awesome.

24:49 The next thing I'm about to tell you though, Brian.

24:50 Okay.

24:51 What's, what's the next thing?

24:52 This, special live event course that I'm running.

24:57 All right.

24:58 Cool.

24:58 So this is happening in, in October and I'm doing a code in a castle event in Tuscany.

25:07 Oh, wow.

25:08 So this is a six day luxurious, core, course in a luxury, luxurious Tuscan

25:17 villa.

25:17 And every morning we're going to wake up and we're going to spend four hours working on Python.

25:23 And then the rest of the day is excursions and winery tours and other stuff around the Italian

25:31 countryside.

25:31 This looks like fun.

25:32 Sounds awesome.

25:33 Huh?

25:33 Yeah.

25:34 So the course is going to be super fun.

25:36 The course is, I called it Python zero to hero, but you don't have to actually be zero.

25:40 Just, you gotta just like, there's probably some areas of this that would be, you haven't

25:45 any, had any experience with.

25:46 So basically it takes you from, I'm maybe learning Python.

25:50 Maybe I know Python, but then talks about async and await MongoDB talks about, we cover

25:57 a FastAPI using HTMX.

26:00 We'll be back to that in just a second and building out awesome web apps and web APIs and

26:05 then performance testing this and then deploying it to Linux.

26:09 If we got time, maybe using Docker as well.

26:12 So yeah, that's, that's what the plan is and it's going to be awesome.

26:16 So if you were interested in being part of this, click the link in your player show

26:21 notes and, so show notes there.

26:23 And yeah, I think I only have a talk Python link.

26:27 So talk Python.fm slash castle is the link and everyone, when they come, they get a

26:32 room in the villa and the room has up to two beds.

26:35 So if you wanted to bring your wife or a good friend, there's actually a separate, set

26:41 of events for the people who are not in the course, but who are attending the event as like

26:45 a companion or something.

26:46 So there's like morning excursions as well.

26:49 Yeah.

26:49 I was reading up on that and it sounds really pretty like some, some good quotes from people

26:53 from last year, enjoying the, the, the, the plus ones, having fun in the mornings.

27:01 So.

27:01 Yeah.

27:02 Awesome.

27:03 Maybe I'll just say the morning track.

27:04 No, I'm just kidding.

27:05 So I forgot to mention this is an extra, extra, extra.

27:07 So this is number one of the extra.

27:09 Okay.

27:10 More.

27:10 Okay.

27:11 More.

27:11 So first one code in a castle, learn Python, FastAPI deployment, load testing, all that

27:17 stuff.

27:17 Hopefully you can be there.

27:18 Number two, I had this awesome use case for HTMX.

27:22 That is so incredibly clean that I just want to give people a feel for it.

27:27 So Brian, if you go to, talk Python, click on the courses, put in your course here.

27:33 Okay.

27:34 you see, it has a price as $59, but if you're European, it would have a price in euros.

27:40 If you were in India, you would have a price and something else.

27:44 So in order to pull that, all that information in, this was usually fast, but periodically

27:51 we'd have to hit our credit card processor for places that are less common.

27:55 I tried to pre-compute all this, but it's like combinatorially out of control.

27:58 So if you're like from a certain part of Greece where there's a certain tax that's different

28:04 than another part of, you know, like all of that factors into what shows up on this page.

28:08 So I just showed them without prices and like, well, what if I could reload, like show the page and then recompute the page with prices.

28:15 And if it takes 10 seconds for 50 API calls to the credit card processor, so be it.

28:20 And maybe you'll see it, maybe you won't.

28:22 But if it's already seen that and it's saved to the database, we'll just show it to you basically.

28:27 Wow.

28:28 Really, really quick.

28:29 So watch this.

28:30 If I refresh it, you can see that it kind of flickers for a second and then the prices come back.

28:34 Cool.

28:35 So all of that is in HTMLX.

28:37 And if you look at the implementation of it, three lines for that entire client side implementation

28:43 of show the page without prices instantly, start a computation to figure them all out,

28:48 get the answer, and then rebuild the page out of that.

28:50 Just div, hx get, some URL, hx trigger to load, render partial.

28:54 This is the implementation that both shows it on the first load without prices and then refreshes

29:00 it and loads it with prices.

29:01 Those three lines and one of them is a slash div.

29:03 Well, that's pretty cool.

29:04 Is that insane?

29:05 Yeah.

29:06 So, yeah, hx for the win.

29:08 Just want to.

29:09 Nice use.

29:10 Encourage more people to use that.

29:12 It lets you do more Python and less JavaScript, right?

29:15 Because most set implementations on the server, which is where it's all Python.

29:18 Yeah.

29:18 And one of those three lines is just the closing of the div.

29:22 So it's really like two lines of code.

29:24 It's really like two lines.

29:25 It's incredible.

29:25 Yeah.

29:26 All right.

29:26 Another one.

29:27 Something I've been recently using.

29:29 And some people will be like, Michael, where have you been all this time?

29:32 Why have you not done this?

29:33 I'll put this out to you as my test candidate.

29:36 Did you know that if you find yourself sitting down to the terminal, SSH into a server, running

29:43 a command, and then leaving often, even if that has like text output and all sorts of responses,

29:48 colored text output, like rich or whatever, you can just run that on your machine using

29:53 SSH to execute a command remotely.

29:56 Is this news to you?

29:57 No.

29:58 So you can say SSH for people who don't know.

30:00 You can say SSH user at host, and then in quotes, some command.

30:06 So like if you want to say tail your log and see what's happening on your server, instead

30:10 of logging into the server over SSH and tailing it, you could just create an alias that says

30:15 SSH user at host, do the tail log thing, and you just type it locally and just boom,

30:19 you're telling log.

30:20 It's beautiful.

30:20 Or whatever you want to do.

30:22 And if you want to run multiple commands, just separate them by semicolons.

30:25 Get a little alias for that bad boy, and off you go.

30:27 Yeah.

30:27 Nice.

30:28 So anyway, that's one of my extras.

30:30 I use it for, so the reboot is built in, but we have an extra command that we do for restarting

30:36 the, we have an application that we often have to restart.

30:39 So doing a single command to SSH and run the restart to restart all the software.

30:45 Do that a lot.

30:45 So.

30:46 Yep.

30:46 Cool.

30:47 All right.

30:47 I told you it's extra, extra, extra.

30:48 There's still more extras.

30:49 Okay.

30:49 Okay.

30:50 Okay.

30:50 We got time.

30:52 All right.

30:52 Yeah.

30:53 These are short.

30:54 So polyfill.io is a CDN, I believe for a JavaScript.

31:00 Polyfill is if a browser doesn't support a feature, but you can implement it in JavaScript

31:05 on top of the features that are there.

31:07 That's a, because include a script that's a polyfill, like add features to an old one,

31:12 an old browser.

31:13 Okay.

31:13 So apparently, according to Bleeping Computer, this thing has been impacted by a supply chain

31:19 attack where a Chinese company acquired the domain and then the script was modified to

31:25 redirect users to malicious and scam sites.

31:27 No.

31:28 And everyone who had that in their web app, 100,000 different websites, the CDN got a

31:33 new version of the script for you.

31:35 Oh, geez.

31:36 Which means it's time for required reading from Wesley Apticker Castle's reasons to avoid

31:43 CDNs in JavaScript.

31:44 I'll do my highlighted one here.

31:46 Oh, wow.

31:47 Look, systemic risk.

31:48 It says one of the CDNs out there supports 12.5% of all websites.

31:54 If that goes down, having 12.5% of the internet vanish is silly.

31:59 We've swung too far towards away from resiliency as a society.

32:03 Privacy, obviously, because they can track everyone who makes a request for that and coordinate

32:08 that across browsers and sites.

32:10 They see speed, but if you're using ACP2, it doesn't matter that much.

32:14 You could use your own CDN security.

32:16 This points out that modern browsers have sub-resource integrity.

32:21 Basically, you put a hash onto it, and if you're using a CDN, put the hash in there.

32:25 That way, if something like this happens, it won't load the page.

32:28 Like, the browser's like, no, it doesn't match.

32:30 I'm not running this, which is good.

32:32 Unfortunately, this doesn't work for libraries that are split into multiple pieces, you know,

32:36 where one thing requires another type of deal as part of it.

32:40 So what to do instead?

32:41 Just download it, is what they say.

32:43 Although what we do, Brian, over at Python Bytes, is we just download it, but then we serve that content back over our own CDN at bunny.net.

32:52 Well, it's not ours, but the one we use at bunny.net, which still gives it all the global reach, but we control whether or not it changes other people, which is awesome.

33:01 And just to keep beating the drum, major ad networks are basically malware delivering funnels, and don't feel bad about ad blockers.

33:10 Mac users served info stealer malware through Google ads, so why not?

33:14 Who wouldn't want that?

33:15 Oh, geez.

33:16 So that's an article on Ars Technica you can check out, but that's my extra, extra, extra, extra, extra hear all about it.

33:23 Okay, nice.

33:24 You got extras?

33:25 I do, but I've got a link that I can't show.

33:29 That's okay.

33:30 So I want you to go to the, like, either in the notes or the private chat and click on that link, and we'll talk about it.

33:37 It's called, I will effing pile drive you if you mention the AI again.

33:41 So it's just a, it's a funny reaction to all this ChatGPT stuff and AI and everything.

33:48 And it's interesting, it's the interesting position.

33:51 So this is somebody that was studying data science.

33:53 They're in, I think they're in college, and they're doing grad, I think grad school stuff now, doing a master's thesis.

34:01 But he's kind of sick of a lot of the hype around AI.

34:06 So there's, it's just an interesting take on it.

34:08 And it's, it's so funny.

34:09 Like, if you'd like to have an alternate, if you're tired of all the hype around AI, and you'd like to, you know, read some, somebody else's perspective, click the link in the show notes.

34:22 And it'll be an interesting read for you.

34:25 The reason why I'm not showing it is because I want to keep this child friendly and safe for this pod, for the live feed.

34:32 So anyway.

34:33 Thanks, Brian.

34:33 Well, check it out.

34:35 That's my, that's my only extra.

34:37 All right.

34:38 Well, let's close this out with a joke, huh?

34:42 All right.

34:42 Yeah.

34:43 Let's do that.

34:43 By the way, I, I have this AI fatigue as well.

34:47 It's like, chat TVT is cool.

34:49 Llama 3 is cool.

34:50 But like, not everything needs to have AI in it.

34:53 And certainly a lot of times software use has just like easiest all persistent bugs because the whole team is like on an AI mission.

35:01 You're like, I don't want any of this junk.

35:03 Could you just make it when I click this that it works?

35:06 Yeah.

35:06 You know?

35:07 All right.

35:07 Off to the joke.

35:08 Over on Reddit, we have something called the HTML hacker.

35:13 We just talked about like the malware, right?

35:15 So this is sort of two sides of the picture.

35:19 Both people don't see either side, really.

35:22 So woman, she says, my boyfriend is a programmer.

35:25 He'll hack.

35:26 He says, don't mess with me.

35:27 My boyfriend is a programmer.

35:28 He'll hack your world into oblivion.

35:30 Meanwhile, the boyfriend on his computer, Google, how to declare variables in HTML.

35:34 Yeah.

35:37 Yeah.

35:38 Both things can be true at the same time.

35:42 He also could be a hacker and still don't know how to declare variables in HTML.

35:45 You never know.

35:46 I don't know how to declare variables in HTML.

35:47 Can you declare variables in HTML?

35:49 No.

35:50 No.

35:51 Okay.

35:51 But you can in like modern CSS and, you know.

35:55 Well, okay.

35:56 So one of the things I think is funny about this is because sometimes in the movies,

35:59 you'll see somebody like pouring through lines of code and then you look at it and it's

36:04 just like the view source of some web page or something.

36:09 It's like, that's not like, you're not hacking anything.

36:12 Guys, guys, I found the source to this web page.

36:16 I'm going in.

36:17 Yeah.

36:21 Wow.

36:22 And I've got the JavaScript next.

36:24 Oh my gosh.

36:24 I can't believe they just published this and don't hide it.

36:28 Yeah.

36:29 So anyway, that's funny.

36:31 Yeah.

36:31 Anyway.

36:31 All right.

36:33 That's it.

36:33 Thanks a lot for a great episode.

36:35 Yeah.

36:35 Fun.

36:36 As always.

36:36 Catch you later.

Back to show page