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


Transcript #46: Spicy lecture notes and unicorn console spinners

Return to episode page view on github
Recorded on Wednesday, Oct 4, 2017.

00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 46 recorded October 4th 2017 I'm Michael Kennedy and I'm Brian Okken and we've got a bunch of cool stuff lined up for you as always But before we get to it, we have some kind of big news, right? We do Yes, we have a new sponsor a brand new sponsor for Python bytes Who's come on to actually support a bunch of the show DigitalOcean. Oh, that's awesome Yeah, so they want to let you guys know about this thing called spaces which is kind of like S3 but 10 times better and the audio you're listening to actually came to you over it. So we'll talk more about that later. I want to hear about spicy code. I want to hear about SciPy lectures. I misread that.

00:41 Spicy SciPy. All the same. Yeah, it's all the same. You threw me off. I'm like what story are you looking at man? Anyway, SciPy lecture notes. I saw I hadn't come across this before but they did an update just recently. It looks like they update it about once a year to make sure it's all current. You know for somebody that's doing just-in-time learning for scientific Python usage this is pretty darn cool. Their tagline is "One document to learn numerics, science, and data with Python" and it runs the gamut. It starts off with a Python language tutorial if you want to take it. You can learn about NumPy, Matplotlib, SciPy. It's got topics like debugging and optimizing, image manipulation and things like how to deal with statistics and machine learning even.

01:30 Yeah, this is really cool. I think a lot of people are getting into data science and getting into Python because of it. But also, I just think this is a great way to learn a lot of these techniques, right? These, these little short focused, I Python notebook style of examples.

01:45 Yeah. And for somebody that really needs to just jump in and find the way they have it set up, It's almost like a table of contents for a book or reference book.

01:54 So you can just jump in and try to learn whatever you need today just right away.

01:59 You know what's cool about the JIT stuff is it has prerequisites.

02:01 It says, like, for example, on the profiling part, it says a prerequisite is you must understand line profiler.

02:08 Oh, okay.

02:09 Yeah, it's pretty cool.

02:10 I thought it was a great source for people that really aren't patient enough to go through a course or really don't know what they need to learn yet.

02:16 What do you think?

02:17 That's like 95% of people.

02:18 Yeah, especially since like we've talked about before, that Python is often a language that people pick up after their primary language.

02:25 Yeah, well, and also, I think we're increasingly asked and expected to build more and more complicated apps bringing together more and more different disciplines.

02:34 So would it be unreasonable to say I would like you to write a web application that talks to the database, but also uses machine learning, and the GPU like that I can see being a totally normal requests now, whereas those used to be their own specialties, right?

02:49 So this ability to jump in and pick up a little bit on demand is only going to be more required, I think.

02:55 Yeah, and they also split up some of the Python stuff into some of the beginner stuff you just kind of have to know to start with, and then they have some more advanced things a little bit later.

03:05 Yeah, nice.

03:06 So the first thing I want to talk about this week is desktop notifications.

03:12 And this caught my eye because I feel like I've said this a couple times, like one of the weaker points of Python is the whole desktop GUI type of thing, right?

03:21 I know you can do it, but it's just not as easy as it should be.

03:25 And so here's a real simple and easy way to build a notification like a desktop Toast type of notification for Linux using Python.

03:33 Well, that's cool.

03:34 Yeah, so I don't know what what you mean by Toast.

03:36 Well, so you're sitting there and there's like a little thing that pops out and say say on Mac it's in the top right and Windows it's in the bottom right by the clock, it would pop up and say, "Your friend just liked your thing on Twitter," or "Somebody invited you to connect on LinkedIn," or "Your server just went down, your boss is paging you, they're upset." >> DAN APPELQUIST I finally get the toast reference.

03:57 Thanks.

03:58 >> DAN APPELQUIST Because it pops up.

03:59 At least in Windows it pops up.

04:00 I guess if you tilt your toaster on the right, then in macOS it's also toast?

04:04 I don't know.

04:05 Anyway, here's an example, a little app that says, "Let's write a thing that will do web scraping against a Bitcoin value location, and it'll go to the website and pull that off and give you a periodic notification of the value of Bitcoin." While that's not super valuable, it does show you a really interesting use case of this package called notify2, which if you have something actually practical and interesting you want to notify people about, that's a pretty cool little use case.

04:33 - I think, actually, I think I might actually use this.

04:35 This would be great.

04:36 - Cool, what would you do with it?

04:37 - For instance, we've got a bunch of remote machines.

04:40 For me, I've got a bunch of VMs that are dealing with builds and whatever, and some way to keep track of them, make sure everything's alive.

04:46 - Yeah, that's cool.

04:47 Like a build, a pass build failed, machine no longer responsive type of notifications.

04:52 Yeah, that's awesome.

04:53 That'd be really fun.

04:54 It looks like a couple lines of code and you got it going.

04:57 So that's really cool.

04:58 Would you consider performance, like if your app becomes much slower after a check-in, like a performance degradation, like a failed build?

05:08 - Well, yeah, definitely.

05:10 - And how would you test for that?

05:11 - Well, funny you should ask.

05:13 The next topic is a tool called pytest Benchmark.

05:18 And this actually came up because, not because of, because I'm actually looking for this.

05:23 I need to have chunks of functionality that we need to know whether or not they're, we need to time them, make sure they're not getting slower with successive releases of the software.

05:32 And what's interesting is the much slower or much faster or just very random timing, people might actually notice that if you're dog footing your own application and you're using it, you might notice this.

05:45 It's the subtle things like a measurement is now, it used to be two seconds and now, and it was for like lots of releases and now it's two and a half seconds.

05:54 Normal users might not notice it right then, but it sure be good to check this.

06:00 So this is a pytest benchmark, and it's a very easy little thing you can add into your code in your pytest testing to say, "Hey, this chunk of code, it needs to be at least this fast." And at first you don't know how fast it should be.

06:14 So there's a lot of tools within it to do some graphing and table driven, showing you what the numbers are right now.

06:22 And then also an ability to have a golden, some golden numbers and save off benchmark data into a JSON file.

06:29 And then on future runs, compare against that. So I'm going to use it.

06:34 Yeah, that looks super interesting, actually. And it has nice graphs over time and things like that. I mean, sometimes timing doesn't matter, but other than like how users feel about it, but you know, in certain types of real time systems or trading systems, there are actual numbers you cannot fall below. If you're processing inbound data in real time and it's appearing every, you know, 100 milliseconds.

06:57 You have to be lower than 100 milliseconds in the processing time, right? Or you won't be able to keep up.

07:01 Often Python's used for other things too, like I've heard that some people use it to control test instruments.

07:08 Yes, that's possible.

07:10 So for instance, checking to make sure even application turn on and measurement times don't slow down because these instruments are used in production lines and it'll slow down your customers production line if you slow down.

07:23 Yeah, absolutely.

07:24 All sorts of factory automation and all kinds of things.

07:27 Cool.

07:28 All right, so that's really nice.

07:29 I definitely if I had a use case for that, I would definitely use it.

07:32 I just don't have anything that I can say it must be this fast or it's a problem, but it still would be cool to actually see the speed over time.

07:40 Now before we get on to the next one, let me say thanks to DigitalOcean and just let you guys know about Spaces.

07:46 So you probably heard of Amazon S3, right?

07:48 I think that was their first thing.

07:51 But like I said, digitalization just really spaces and I definitely think it's better.

07:57 Soon as I heard about it before they even said, Hey, I want to sponsor the show and have you tell the world about it.

08:01 I'm like, I'm switching to this thing.

08:02 So for one, it's like nine times cheaper than AWS.

08:07 It's super predictable pricing.

08:09 There's all kinds of benefits.

08:10 You can use the same tools as you use to manage your s3 thing.

08:14 So same API's and everything.

08:16 So for example, I use this cool program called transmit for my Mac to manage all my files in S3, just pointed at DigitalOcean Spaces and it just keeps working.

08:25 It's awesome.

08:26 So it's like $5 a month, 250 gigs for free in storage, a terabyte for free in bandwidth.

08:33 That is quite expensive if you pay nine cents per gigabyte at AWS, but it's completely free here.

08:41 And it's a really nice service just as fast, but much more predictable.

08:46 And even inbound data is 100% free.

08:48 So check them out.

08:49 It's really a super simple API.

08:51 It's one you're familiar with the tools work and you can actually get whether you're a new or existing customer, you get two months free.

08:58 If you just go to do.co slash Python do co slash Python.

09:04 So check it out.

09:05 That's great.

09:06 Cool.

09:07 Yeah, it's super cool project.

09:08 out with it and I'm happy to be using it for this podcast and other stuff.

09:12 So we've talked, you've talked more than I have, but we both talked a fair amount about projects how they do packaging, Python packaging, how you should structure those, and so on.

09:23 So I want to highlight an article that is, it's a fun article, but it's super in depth and a deep look inside of how Python works, and how packages are built and why they're built that way.

09:35 It's an article by Vicky Boykus, and it's called Alice in Python Project Land.

09:40 So it's got some cool little graphics and stuff, but the idea is like, she's a data scientist learning data science and those things, so doing a lot of Java and doing a lot of Python.

09:50 It's like, look, Python is so much better, except for it's really hard to package up things.

09:56 Like, how do I take some code that I've written and make it so that I could give it to you and you could use it, for example.

10:03 So instead of just going, These are the four steps you do to create a Python package.

10:06 She said, let's look at the internals of how Python actually works and how it runs, how it understands and links things together.

10:13 And so you not just know how to put things together, but you understand why.

10:18 So very, very interesting article, pretty in depth.

10:21 So packaging has always been kind of this weird thing that you just follow the steps.

10:24 You can check this out.

10:25 It's a good article.

10:26 Like you said, it's in depth, which makes it kind of a long article, but the writing is really good.

10:31 So it moves along pretty fast.

10:33 Yeah, it sure does. It sure does. And answers a lot of questions like, should you set up tools to use pip and should what does dunder and net.py do? Should I mess with Python path?

10:43 Should I not? And another thing that I saw that she referenced in there was pretty cool. It's called pip rex. Have you seen this? No. Yeah. So I think pip rex, you pointed at your code, and it looks at all your imports, and it then knows what to create for your requirements.txt.

10:56 Cool. So instead of remembering like, oh, yeah, there was that thing that I use Colorama or or whatever and I forgot to put in the requirements file so it's not gonna work.

11:04 Like this will just discover it.

11:05 It's really cool.

11:06 So, yep, if you wanna get like an understanding of how Python packaging and assembly of modules at runtime works, definitely check out this article.

11:15 It's super approachable, but well done.

11:17 - Next article, how to teach technical concepts with cartoons.

11:21 Love technology.

11:22 So I personally, since I came from computer science from the art, fine arts actually, I started out in fine arts.

11:29 And I actually gave up because I was frustrated with my ability to draw.

11:34 But drawing things to help people understand concepts, it's very, it helps.

11:40 It's easier to understand things.

11:41 And nobody expects you to draw really great pictures.

11:45 This article starts off, I love this, it starts off with just saying that she draws not that great.

11:51 It has really three horrible pictures of a dog, a cat, and an elephant.

11:55 I don't think I can do better, but they're not great drawings.

11:58 But just then going through and talking about how people should use drawings more when trying to teach things and some tips on making them more personable.

12:07 I think it's a really cool idea.

12:08 You certainly can personalize and humanize technical concepts if you use pictures.

12:15 Like you said, they don't have to be super fancy.

12:17 So she has a dog, a cat, an elephant and those sorts of things.

12:20 But you know, not far down, she says, oh, let's do something about a mutex and actually represents how mutexes are used to like for shared memory or something like that, right?

12:32 And it's completely approachable, but somehow it just makes it much more.

12:36 If you looked at the formal definition of a mutex, like, oh my gosh, what is that thing?

12:41 But here it's like, oh, okay, well, that's totally simple.

12:43 I think you can really convey a lot and sort of disarm people with some nice drawings.

12:49 One of the things I like about this article as well is it itself is a mix of hand lettering just for normal printing and some simple drawings with text. That's what the tutorial is and it breaks it up a lot and I think a lot of technical people when they're trying to teach something they'll think a drawing is a good idea but then they'll get out a tool to make all the lines straight and draw it with vector graphics and sometimes I think just a pen and paper might help convey the information better. Yeah yeah absolutely I think this is really cool and hopefully inspire some people to do a little more a little more freehand stuff. It doesn't always have to be perfect. So keeping it graphical for our last item, I want to share the Halo with you. So Halo is a project called Beautiful Terminal Spinners in Python, which is what it sounds like. It's a really simple library that will give you sort of I'm loading or I'm working or I'm thinking type of spinners and a lot of cool features. So you have a little spinner go around and you have different styles. You have successful outcomes, outcomes, failed outcomes.

13:53 So like this little spinner will spin and then it'll go to like a check mark if it succeeds.

13:57 Or if it fails, it'll go to like a cross and you could make it red or something like this, right?

14:02 So that's, that's really cool.

14:03 We talked about progress bars, where you have the progress going across, you know, the, I think one of the better ones is TQDM.

14:11 Sometimes you don't know what the progress is going to be, right?

14:14 Like I hate progress bars that go it's, it's 5%, it's 5%, it's 90%, 91%, and then it goes forever and then finally it's done right there's a great xkcd i'll put in the show notes it's really fun about the guy who built the windows progress bar file copy progress bar but sometimes progress bars aren't the answer there's a reason i'm bringing it up but little spinners sort of solve that problem because it doesn't indicate progress it's just like we're busy and so here's a really cool way to put that into your program it's very simple and it's it really looks nice too yeah definitely and it has a unicorn a colorful unicorn who doesn't want that >> I'm not sure how the unicorn displays progress though.

14:51 >> No, maybe in the horn.

14:52 >> That would be cool if the horn had colored.

14:56 >> Yes, like the horn flashed like rainbow.

14:59 >> Yeah.

15:00 >> I don't know if it does that or not, but it should.

15:03 But if you're looking to add some user feedback like, "Hey, we're busy, we're not locked up, Halo, super easy, very cool." That's it, Brian, for our topics. You got anything else?

15:13 >> I don't think they would have made a full story, but I wanted to let people know that the Python, I think it's 363 is out now.

15:21 So go upgrade.

15:22 I don't know if there's anything major in it.

15:24 I haven't looked through it, but it's around.

15:26 So keeping current is good.

15:28 Then there's also a bug fix release I noticed in pytest.

15:32 That's around. I'm not sure what's in it, but again, it's around so people can pay attention.

15:36 >> Yeah. Okay, very cool. So check those out.

15:39 >> The last thing I wanted to mention is I haven't been, I warned people that I was going to start podcasting again, but it took me a while.

15:46 You warned him.

15:47 Look out, I'm going to do it.

15:48 Yeah, there are a couple.

15:49 So at the end of September and just a couple days ago, I released a couple different test and code episodes, one of them related to the testing pyramid.

15:58 And the last one, 32, is an excellent one by an amazing speaker.

16:02 It's with an amazing speaker named David Hussman.

16:06 And he's a brilliant man.

16:07 Yeah, that's really cool.

16:08 And I'm glad you got that one out.

16:09 That's awesome.

16:10 How about you?

16:11 Anything new going on?

16:12 No, nothing new.

16:13 I'm working on my courses like crazy.

16:14 But the announcement's going to have to wait until next week for anything to be actually out for anyone to check out.

16:20 >> Well, thanks a lot for doing this today.

16:21 >> You bet.

16:22 It was great to catch up with you and share all these ideas with everyone.

16:25 Catch you later.

16:26 Thank you for listening to Python Bytes.

16:28 Follow the show on Twitter via @pythonbytes.

16:31 That's Python Bytes as in B-Y-T-E-S.

16:34 And get the full show notes at pythonbytes.fm.

16:37 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

16:42 a lookout for sharing something cool.

16:44 On behalf of myself and Brian Okken, this is Michael Kennedy.

16:48 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page