Monitor errors and performance issues with

#92: Bonus: Python Bytes Crossover: Python 3.6 is going to be awesome, Kite: your friendly co-developing AI Transcript

Recorded on Monday, Dec 12, 2016.

00:00 Hey everyone, Michael here. It's just about time to close out 2016, isn't it? Well, I have a few comments and a bonus episode for you. So first of all, thank you so much for listening to talk Python and helping make it a success. It really means a lot to me. And I love all the listeners. I love the community around it and just want to say thanks for taking the time and subscribing and listening. I've had so much fun that I decided to start a second podcast, you may have heard of it. It's called Python bytes. And I launched this podcast with Brian arkin. And the whole idea behind it is that we're going to bring Python headlines and news and kind of new cool items to your earbuds right. So every week, we'll try to cover some timely news. And maybe just something cool that we found it's much shorter. It's not really an interview format, or long form format as I think of talk Python. So I've decided to post this single episode of Python bytes to the talk Python listeners, so everyone gets a chance to check it out. I know many of you have extra time around New Year's. So here's one more episode for you to listen to while you're driving to and from relative's house. If you like what you hear, just visit Python and subscribe to get episodes like this weekly. So I want to wish you all happy holiday season and Happy New Year. And I'll be back on talk Python in a few days with software carpentry in the sciences with Jonah From Software dash Until then, enjoy this episode with Brian and myself and have a great break. This is Python bytes Python headlines and news delivered directly to your earbuds. It's episode six recorded Monday, December 12. This episode's brought to you by robar they help take the pain out of errors. Thank you so much rhobar for sponsoring the show. And this is Michael Kennedy, one of your hosts. I'm here with Brian Aachen, my co host Hello, Brian. How's it going, man?

01:46 Hello. It's going really good. Good.

01:47 Good. I this year has gone by quickly, hasn't it?

01:51 It's gone. It's super fast. Yeah, I

01:53 feel like everyone was fixated on the election because it was so unique. And then kind of nobody knows what to do with the rest of the year. So I'm gonna go on vacation. How about you?

02:03 Yeah, I'm gonna, I'm gonna start writing. So

02:06 yeah, you got a book to finish. And anyway, so the point is, this is actually our last episode of the year. So I want to say thanks to everybody who subscribed and listened and shared this this podcast with their friends. We're taking a break, and we will be back. First thing in January 1 week, we'll have even more news to share with me.

02:25 Yeah, that'll be the like three weeks of stuff to catch up on.

02:29 Yeah, hopefully no drama. Okay. So what's the first item you want to share with everyone? What do you find? Well, there's

02:34 an article by Dan Bader, make your Python code more readable with custom exception classes. This is great. He wrote up a little tutorial, along with a five minute video where he walks through stuff, he talks about the including your own exception classes can make your errors more readable in your within your code and also communicate to the users of your functions or whatever your intent and what the errors are. And also, you can add more context, I like it, because it's one of those things that I was afraid to add custom exceptions. And it's really just pretty darn easy. The main points, I think, is to remember to derive from either exception, or one of the other built in Python exceptions,

03:15 like value error, or something like that. Right?

03:17 Yeah. Whatever it sort of makes sense. And, and it's, it's a good one. I also wanted to add that if you are there's extra things you should do if you're releasing a package, and or even within within your company, I think it's good to derive from your own, create a custom exception, and then derive all your other exceptions from that one. And I got that tip from another article that will link to in the show notes by Julian danjou.

03:44 Yeah, yeah, that's

03:45 a really great point, actually. Because it would be great to do try accept all the errors from this package. Like whatever's happening in here. I want to start by handling those and maybe get more specific ones. Maybe not. But yeah, I hadn't really thought about that. The make your own special base exception,

04:05 even the reverse, try to do specific first and then and then do a catch all of those. And then if it isn't one of your package ones, then you can also still catch the general exception and do something different there.

04:17 Yeah, that's cool. There's two, there's a couple things about this article. I like when Dan Bader is doing a bunch of cool videos on YouTube, he really seems to be putting a lot of effort to frequently get those out. And so here's an article that takes like five minutes to read, but there's also a five minute video screencasts go along with it. So well done on that, Dan. And then more generally, this idea here makes it easier for one of my favorite programming patterns, which is also quite pythonic is that it's the pattern is it's easier to ask for forgiveness than permission. As opposed to like the c++ style before you leap programming model where you test the heck out of everything that you try thing you just hear you just do it if it throws an exception, you know, you catch it and then accept lock and it's all good.

05:00 Yeah, definitely like, at a high level. Like, for instance, if I were as an example, if I were using requests, I could have a special handler that dealt with exceptions for requests and know that that I, because I understand what part of my system is dealing with that. I could handle it in one place.

05:18 Right? Absolutely. Yeah. Could not contact server, the web server seems to be down something like this, right? Beautiful. Wouldn't it be awesome if like, artificial intelligence could just like sit there and just like help you code? I mean, we all know of AI for like Siri and silly things like that. But I feel like actually 2016 is a little bit where the future kind of intersected with now like things became the future came to us. There's so many things with AI that are really awesome. Like there was several AI's that actually, on their own invented encryption. But what I want is an AI to help me as a developer, how about you?

05:54 Sounds great.

05:55 Yeah, that'd be super cool. So So I actually ran across this thing. One of the listeners, Alberto Diaz was nice enough to send me a link in an email, say, hey, there's this thing that is so cool, you must check it out. It's not technically built in Python, but it really supports Python developers in a crazy good way. So there's this thing called kite And it's in private beta, we were lucky enough to get some early access to it. And what it is, is like you install it in your OS, and it sits in kind of like a sidebar, and it takes up maybe like, I don't know, a fifth of your screen, if you have two screens, and you know, stick it on the other one. And it watches what you do in all sorts of different programming environments. In Sublime Text in Visual Studio code in PI charm. Even vim or Emacs has many, many plugins, as you type, it helps you. Alright, so if you're writing Python code, and you type import space, it'll show you a list of the most popular packages. If you type R, it will show you the list of most popular packages that start with our like request right at the top. Yeah, and then once you import a thing, it'll start showing you documentation about it. Here's some examples on how to use that thing you just imported. As you start to, like, you know, interact with it like request dot, it'll say, well, the most commonly called function here is get you want to see some examples how to use request dot get or like the documentation. And it just, it just really is quite cool how much it knows. And you know, it does auto completion. Like many editors do, it'll, it'll like show you on the left, like, here's the things you could complete. But what I like about it is it uses like crowdsourcing for popularity. So there's, like, you know, 10,000 developers working on this. And you'll say, Well, this is the most popular completion in this situation here. based not just alphabetical or something. So I think it's cool. There's, there's a great video you have to watch. If you go check this it's like right there in the homepage.

07:45 Um, I'm looking forward to playing with it. Yeah. you'd mentioned it seems like AI pair programming. And does your sound like that?

07:53 It's it's quite interesting. I feel like it's more like an artificial intelligence mentor, rather than paired programmer like, it's they're going, oh, by the way, did you know that the you actually can call this function? Oh, that package is really cool, because it has this thing you might not know about? It's kind of like the wiser, wiser version rather than like, you know, pair programming, but I think it's great.

08:12 Oh, definitely looking forward to trying that.

08:13 Yeah, for sure. I hate it when my data gets messy.

08:17 Yeah, definitely. Um, so there's an article by I'm gonna even try this, john Nicolas, hold, I think tidy data in Python, this article was pretty interesting, it caught my attention. Because I often have data that's in a format that I can't use right away, and I need to transform it into something else. And I didn't ever think of it like changing tables around and completely changing things automatically. Anyway, they started to give some, some attributes of what problems to look at and datasets, he based it on a paper named tidy data by Hadley Wickham, he takes the idea of the paper, and then transfers it to into Python, and how to utilize in Python with a panda's library. And like, so this seems very abstract right now. But he has some examples of data that's, that's really data is in the column headers, he has some attributes to look for, like each variable forms a column and contains a value. And each observation forms a row. And the type of observation units form a table in, it still sounds kind of complex, or kind of abstract. But the examples really are pretty easy to follow. And it's just a neat idea of, of taking a look at your data and making it more useful.

09:39 I had never really thought about data in the sense that but it seems to me like this talks about how you put your data together so that you'll be it's most natural to take advantage of it with things like pandas, and the various data science tools and all sorts of languages, but he's focused on Python which is extra cool. And so he has several examples on on, you know, do things this way, not that way and your life will be much easier. And I just never thought of systemising that I guess.

10:07 Yeah, I also looking at the different comparison of before and after tables, you can definitely see how it's definitely the the converted table is easier programmatically, but the from table, the dirty one is it's it's more broken up, like how people look at stuff, I didn't think there would be a difference. But it does appear to be it's, it's easier for to visualize smaller tables as people but as computers, we need things a little bit more broken down. Yes, cool.

10:37 So if you've got a lot of data, especially in tabular form, check that out, we're going on break, I'm actually heading out on vacation somewhere away from home. And, you know, I'm still taking my laptop with me, because that would be kind of insane. But you know, our sponsor robar, they, they will gonna let me just chill out and not worry about whether the web app is working or not check it all the time. Like, I might not use my computer for a few days. And unless I get notifications on my phone, or you know, text messages, or slack or something like that saying, Hey, your website's down, there's this problem. Yeah, things are gonna be good. I'm not gonna worry about it. That's because I got rhobar integrated with all the talk Python stuff, which is really cool. So if there's a problem, you know, I can just read what the error is, and probably fix it pretty easily. So all the Python byte listeners, they can have the same peace of mind, they just have to go to slash Python bytes and sign up for the free tier. Sounds cool, huh?

11:25 Sounds very good. Yeah,

11:27 that's good. It's good to be on vacation. And, you know, not worry about things working, just set up the error notifications, and you're all good. I'm really excited that there's a new version of Python. I think people are starting to move on from legacy Python. And there's just ended this week, there's going to be one more reason to do so. So we actually have as our next item, a video conference presentation at pi con Canada 2016. by Brett cannon. He did a talk called what's new in Python three. And I think it's interesting. If you look at all the paps and all the stuff that's coming and you think Well, okay, they're doing little tweaks here. I guess it doesn't new string formatting, or whatever. It turns out, they're over 16 peps in Python three, six. And that's more than any peps that have been in Python three, other than the actual creation of Python 3.0 itself. That's pretty cool. Right?

12:17 Maybe we should have had another roll before now then May. But I'm excited for all these.

12:23 Yeah, it's gonna be great. It's gonna be great. The reason I liked this video, and I want to point it out is we could all go to you know what's new. In Python three, we can read the list like, Okay, well, here, dictionaries will be ordered. There's now a private identifier, or like a version number on dictionaries, like okay, whatever, who cares? This gives you the story behind all the changes come into Python three, six, like, why did the core developers have which bread is one thing that this is a good idea? Like, how does it help? What what really problem? What problem? Are they really trying to solve deep down when they made this change? And it really is a cool look inside? What's coming with Python? Three, six,

13:00 that sounds great.

13:02 I think it's good. So Python three, six, release candidate. It's available right now, if you want to download it, but you know, if you can wait, like five days, you should have the final version of Python three, six, they did something with virtual environments, right?

13:14 Yeah, this is one of the things I stumbled across, I think it was in a Reddit line somewhere the command command line command of pi, V and V, which I can't remember which version that came in on one of the three O's, that's being deprecated. And the reason and they want people to use the dash m, v and v, instead. And that's so that you specifically tell the virtual environment system, which Python to use, and makes the programmer No need to know how to get to Python first, before they create a virtual environment. I think that it totally makes sense. It's just something to point out. I think it's important. I'm going to have to actually edit my book because of this because they recommended pi V and V in mind. So

14:01 time to recommend it. Yeah. That's cool. I do think it is good. I mean, you can say Python three dash dash version, you'll see what that is. And then you can say Python three dash m v v, and then that's the thing you're going to get right. So it is a little more clear, I guess. Very cool. It wouldn't be a week in Python without some form of testing or code coverage. Right?

14:21 Yeah, definitely. And Ned batchelder, who we all owe it some gratitude for for coming up with for taking over the coverage package. He's, I interviewed him about that on episode 12 of testing code. But he's planning a new feature for coverage pi, which will tell us which so when you when you run a coverage report, also, what functions caused this or how did you get this stuff covered? And he covers it in an article he taught he titled who tests what this is a discussion about kind of how I liked the discussion because those those people knew to come Coverage can kind of peek inside and see you the different stages of how coverage works. It goes through measurement and storing the data and then combining the data and reporting because you can have multiple tests, most multiple runs, and combine them into one report this idea of trying to figure out which code was covered by which tests is how it started, but he comes up with some some reasons why there may be more more uses than just in testing. And it's it's a good discussion. But part of one of the things he why he wrote this article is, is to try to get some help. He wants some feedback. So some of the questions are, he discusses the memory, memory usage and the data model? And he wants to know if there's something we need more sophisticated problem solving on this? Or should we be more conservative with memory, and then the output, the output right now is intended to be in Jason, but he wants to know if somebody could use a different data format. And I like the direction he's going with it. And I think I'll use it. And I encourage anybody that has sort of a non standard usage of coverage to take a look at this article and give Ned some feedback.

16:08 Yeah, I haven't really liked it as well, because a lot of times, unless you're actually a contributor to the project already feel like the fate of the thing has already determined, but this was much more like, Look, we have this challenging problem. These are the ways in the trade offs. We're thinking about the ways we're thinking about solving the trade offs we're contemplating. We're not sure where to go, if you want to help. Here's how to help if you want to give us feedback before we jump in and go the wrong direction. Do it. So this is a really cool article just on philosophy as well.

16:37 Yeah, I think it's

16:38 great. And being able to know which tests actually triggered the covered line when you run 1000 tests. Well, with these three, like, that's pretty interesting. Yeah. And,

16:46 you know, before I talked to him, I didn't realize that there was there were so many features of covers, I didn't realize like being able to have multiple test runs and combine that data and HTML output and things like that. It's pretty

16:57 cool. Yeah, quite cool. quite cool.

16:59 So what do you got for us, Michael?

17:01 I got one, one final, glorious topic for the rest of the year to round out 2016. So here it is, threaded, asynchronous magic and how to wield it. So this is a really cool article by Christian Medina. You know, we had talked about that. I don't remember exactly the title. But that async IO tutorial that was like the G event tutorial remade for async IO and Python three, four. And we're like, well, wouldn't it be cool if there's a great one on async and await like the really the the truly new cool features of Python, four, threading and parallelism? Well, Krishna Medina wrote, he wrote a really nice one, and it has a bunch of bite sized examples. You can, you know, they're not too they're not too large, but they don't seem entirely fake. So here's one example of like sending email notifications, sort of asynchronously. But it's like, you know, but you realize there's no a wadeable asynchronous like way to send mail in Python. So well, we're just gonna block but at least we can use this AC guy will loop for that. That's cool. And then also talked about the ai o HTTP library, which is an HTTP client server for async. I O, and how to do a bunch of parallel web requests. So we often think about requests being the primary way that we do programming against web services, and generally HTTP. But this is another option that's really simple that fits exactly into the async. io. So you can easily block on the network calls, which will then free up the thread to go do other stuff, because it knows it's waiting on the network. That sounds cool. Yeah, that's really cool covers things like task scheduling tasks, scatter, gather files of programming, and then even moving the async i o loop to a background thread. So you don't block up your main thread, you kind of have a place to put all the asynchronous work and let it run on that other one thread, which is pretty cool. So yeah, so thanks, Christian for Gina. Got to meet him at pi con last year. And so that was fun. And hopefully everyone else is going to pi con if you don't have your tickets yet. You need to be getting it right, right.

19:03 Definitely. I

19:04 missed out last year. So don't be sad tickets before they sell out because this I'm sure it will sell out it sold out early last year and

19:11 pluses in Portland in Portland rocks.

19:14 Portland. Definitely rocks. It's gonna be weird. We're gonna be keeping it weird. All right. Well, that's it for me. I don't really have a whole lot of news to share, other than just saying thanks, everyone for listening. You know, for our new podcast, it's been fun to do for you. And I appreciate all the feedback.

19:29 I appreciate it, too. Speaking of feedback, we did get one person I think it's Harry J. Hope I didn't pronounce that wrong. On Twitter said that he listened to Episode Three. And I had mentioned that a library called pi ninny that don't know if I'm pronouncing that right. But I assumed that these were that maybe it was named after the Knights who say knee.

19:51 We thought that would be fun anyway.

19:53 Yeah, definitely. But LBJ tells me that this is not true. It's named after her Sanskrit. grammarians with a PA. I don't know how to pronounce that either. It's pa Ni Ni. Anyway, thanks.

20:06 I like fact checking. That's good fact checkers. Awesome. I'm just going to call it Panini.

20:13 Ne Ne.

20:14 Yeah. Just know it has a different origin. Okay. Well, thank you, Brian. Thank you everyone for listening. Thank you rhobar for sponsoring the show. We will see you all in January. Until then, you know, enjoy the Winter Wonderland. Unless you're down in Australia. Then have a nice summer. Yeah, definitely. See you next year. Yeah, see you next year. Bye, everyone. Bye. Thank you for listening to Python bytes. Follow the show on Twitter via at Python bytes that Python bytes as mb yts and get the full show notes at python If you have a news item you want featured just visit Python by set FM and send it our way. We're always on the lookout for sharing something cool. On behalf of myself and Brian knockin. This is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon