Latest / Talk Python To Me / #92: Bonus: Python Bytes Crossover: Python 3.6 is going to be awesome, Kite: your friendly co-developing AI
Transcript
- 0:00Hey everyone, Michael here. It's just about time to close out 2016, isn't it? Well, I have a few
- 0:06comments and a bonus episode for you. So first of all, thank you so much for listening to Talk
- 0:11Python, helping make it a success. It really means a lot to me and I love all the listeners. I love
- 0:17the community around it and just want to say thanks for taking the time and subscribing and
- 0:22listening. I've had so much fun that I decided to start a second podcast. You may have heard of it.
- 0:26It's called Python Bytes and I launched this podcast with Brian Okken. The whole idea behind
- 0:31it is that we're going to bring Python headlines and news and kind of just new cool items to your
- 0:37earbuds, right? So every week we'll try to cover some timely news and maybe just something cool that
- 0:42we found. It's much shorter. It's not really an interview format or long form format as I think
- 0:46of Talk Python. So I've decided to post this single episode of Python Bytes to the Talk Python listeners
- 0:53so everyone gets a chance to check it out. I know many of you have extra time around New Year's.
- 0:57So here's one more episode for you to listen to while you're driving to and from relative's house.
- 1:03If you like what you hear, just visit pythonbytes.fm and subscribe to get episodes like this weekly.
- 1:08So I want to wish you all a happy holiday season and happy New Year. And I'll be back on Talk
- 1:14Python in a few days with Software Carpentry and the Sciences with Jonah from software-carpentry.org.
- 1:21Until then, enjoy this episode with Brian and myself and have a great break.
- 1:25This is Python Bytes. Python headlines and news delivered directly to your earbuds. It's episode 6,
- 1:32recorded Monday, December 12th. This episode is brought to you by Rollbar. They help take the pain
- 1:37out of errors. Thank you so much, Rollbar, for sponsoring the show. And this is Michael Kennedy,
- 1:41one of your hosts. I'm here with Brian Okken, my co-host. Hello, Brian. How's it going, man?
- 1:45Hello. It's going really good.
- 1:47Good, good. This year's gone by quickly, hasn't it?
- 1:50It's gone. It's super fast.
- 1:52Yeah. I feel like everyone was fixated on the election because it was so unique. And then
- 1:58kind of nobody knows what to do with the rest of the year. So I'm going to go on vacation. How about
- 2:03you?
- 2:03I'm going to start writing. So yeah, you got a book to finish, man. Anyway, so the point is,
- 2:10this is actually our last episode of the year. So I want to say thanks to everybody who subscribed and
- 2:15listened and shared this podcast with their friends. We're taking a break and we will be back first
- 2:22thing in January, first week. We'll have even more news to share, won't we?
- 2:26Yeah. That'll be, I have like three weeks of stuff to catch up on.
- 2:29Yeah. Hopefully no drama. Okay. So what's the first item you want to share with everyone? What
- 2:34do you find?
- 2:34Well, there's an article by Dan Bader, make your Python code more readable with custom exception
- 2:40classes. This is great. He wrote up a little tutorial along with a five minute video where he
- 2:46walks through stuff. He talks about the, including your own exception classes can make your errors
- 2:51more readable within your code and also communicate to the users of your functions or whatever your
- 2:58intent and what the errors are. And also you can add more context. I like it because it's one of
- 3:03those things that I was afraid to add custom exceptions and it's really just pretty darn easy.
- 3:08The main points I think is to remember to derive from either exception or one of the other built-in
- 3:14Python exceptions.
- 3:15Like value error or something like that, right?
- 3:17Yeah. Whatever sort of makes sense. And, and it's a, it's a good one. I also wanted to add that if you
- 3:25are, there's extra things you should do if you're releasing a package and, or even within, within your
- 3:31company, I think it's good to derive from your own, create a custom exception and then derive all your
- 3:37other exceptions from that one. And I got that tip from another article that we'll link to in the show
- 3:42notes by Julian Danju.
- 3:44Yeah. Yeah. Yeah. Yeah. That's a really great point actually, because it would be great to do try
- 3:49except all of the errors from this package. Like whatever's happening in here, I want to start by
- 3:54handling those and maybe get more specific ones. Maybe not, but yeah, I hadn't really thought about
- 4:01that. The make your own special base exception.
- 4:04even the reverse try to do specific first and then, and then do a catch all of those. And then
- 4:10if it isn't one of your package ones, then you can also still catch the general exception and do
- 4:16something different there.
- 4:17Yeah. That's cool. There's two, there's a couple of things about this article. I like
- 4:20when Dan Bader is doing a bunch of cool videos on YouTube, he really seems to be putting a lot of
- 4:25effort to frequently get those out. And so here's an article that takes like five minutes to read,
- 4:29but there's also a five minute video screencast to go along with it. So well done on that, Dan.
- 4:34And then more generally, this idea here, it makes it easier for one of my favorite programming
- 4:40patterns, which is also quite Pythonic is in that it's the pattern is it's easier to ask for
- 4:45forgiveness than permission, as opposed to like the C++ style. Look before you leap programming
- 4:51model where you test the heck out of everything that you try thing. You just here, you just do it.
- 4:55If there was an exception, you know, you catch it and then accept block and it's all good.
- 5:00Yeah. I definitely like a, at a high level, like for instance, if I were, as an example,
- 5:05if I were using requests, I could have a special handler that dealt with exceptions from requests
- 5:11and know that, that I, cause I understand what part of my system's dealing with that. I could
- 5:16handle it in one place. right. Absolutely. Yeah. Could not contact server. The web service
- 5:21seems to be down something like this, right? Beautiful. Wouldn't it be awesome if like artificial
- 5:26intelligence could just like sit there and just like help you code? I mean, we all know of AI for
- 5:33like Siri and silly things like that, but I feel like actually 2016 is a little bit where the future
- 5:39kind of intersected with now it like things became the future came to us. There are so many things
- 5:44with AI that are really awesome. Like there was several AIs that actually on their own invented
- 5:49encryption. But what I want is an AI to help me as a developer. How about you? Sounds great. Yeah.
- 5:55That'd be super cool. So, so I actually ran across this thing. one of the listeners,
- 5:59Gilberto Diaz was nice enough to send me a link and, an email and say, Hey, there's this thing
- 6:04that is so cool. You must check it out. It's not technically built in Python, but it really supports
- 6:10Python developers in a crazy good way. So there's this thing called kite at kite.com and it's in
- 6:15private beta. We were lucky enough to get some early access to it. And what it is, is like you install
- 6:20it 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
- 6:25your screen. If you have two screens and you know, stick it on the other one and it watches what you do
- 6:30in all sorts of different programming environments in sublime text and Visual Studio Code in PyCharm,
- 6:36even Vim or Emacs has many, many plugins. As you type, it helps you. All right. So, if you're
- 6:45writing Python code and you type import space, it'll show you a list of the most popular packages. If you
- 6:51type R, it'll show you the list of the most popular packages that start with R like request right at the
- 6:55top. Yeah. And then once you import a thing, it'll start showing you documentation about it. Here's
- 7:00some examples on how to use that thing you just imported. As you start to like, you know, interact
- 7:04with it, like request dot, it'll say, well, the most commonly called function here is get, you want to
- 7:08see some examples, how to use request dot get or like the documentation. And it just, it just really
- 7:14is quite cool how much it knows. And you know, it does auto completion. Like many editors do it'll,
- 7:21it'll like show you on the left, like, here's the things you can complete. But what I like about it is
- 7:25it uses like crowdsourcing for popularity. So there's like, you know, 10,000, developers
- 7:32working on this and they'll say, well, this is the most popular completion in this situation here.
- 7:37Base, not just alphabetical or something. So I think it's cool. There's, there's a great video.
- 7:41You have to watch if you go check this out at kite.com. It's like right there in the homepage.
- 7:45I'm, I'm looking forward to playing with it. Yeah. You, you'd mentioned it seems like AI pair
- 7:50programming and, does sure sound like that. It's, it's quite interesting. I feel like it's
- 7:55more like an artificial intelligence mentor rather than paired programmer. Like it's going,
- 8:00Oh, by the way, did you know that the, you actually can call this function? Oh,
- 8:03that package is really cool. Cause it has this thing you might not know about. It's kind of like
- 8:07the wiser, wiser version rather than like, you know, pair programmer, but I think it's great.
- 8:12Oh, definitely looking forward to trying that. Yeah, for sure.
- 8:14I hate it when my data gets messy. Yeah, definitely. so there, there's an article,
- 8:20uh, by, I'm going to even try this John Nicholas hold, I think tidy data in Python. This article
- 8:28was pretty interesting. It caught my attention because I often have data that's in a format that
- 8:33I can't use right away and I need to transform it into something else. And I didn't ever think of it
- 8:39like, changing tables around and, and completely changing things automatically. Anyway,
- 8:44this article gives some, some attributes of what problems to look at and data sets. He based it on
- 8:50a paper named tidy data by Hadley Wickham. He takes the idea of the paper and then transfers it to,
- 8:59into Python and how to, how to utilize it in Python with the pandas library. And like, so this seems
- 9:06very abstract right now, but he has some examples of, data that's, that's really data is in the,
- 9:12the column headers. He has some attributes to look for, like each variable forms a column and contains a
- 9:19value and each observation forms a row and the type of observation units form a table. And it still sounds
- 9:28kind of complex or kind of abstract, but the examples really are pretty easy to follow. And I, it's just a,
- 9:34a neat idea of, of taking a look at your data and making it more useful.
- 9:38I had never really thought about data in this sense, but it seems to me like this talks about how you put
- 9:44your data together so that you'll be, it's most natural to take advantage of it with things like
- 9:49pandas and the various, data science tools and all sorts of languages, but he's focused on Python,
- 9:56which is extra cool. And so he's, he has several examples on, on, you know, do things this way,
- 10:01not that way. And your life will be much easier. And I just never thought of systemizing that, I guess.
- 10:06Yeah. And also, looking at the different comparison of before and after tables, you can
- 10:12definitely see how it's definitely the converted table is easier programmatically, but the from table,
- 10:19the, the dirty one is, it's, it's more broken up, like how people look at stuff. I,
- 10:26I didn't think there would be a difference, but it does appear to be it's, it's easier for,
- 10:30to visualize smaller tables as people, but, as computers, we need things a little bit more
- 10:36broken down.
- 10:37Yeah, it's cool. So if you've got a lot of data, especially in tabular form, check that out.
- 10:40We're going on break. Like I'm actually heading out on vacation somewhere away from home and,
- 10:46you know, I'm still taking my laptop with me because that would be kind of insane, but you know,
- 10:50our sponsor roll bar, they, they were going to let me just chill out and not worry about
- 10:55whether the web app is working and not check it all the time. Like I might not use my computer for
- 10:59a few days unless I get notifications on my phone or, you know, text messages or Slack or something
- 11:05like that saying, Hey, your website's down. There's this problem. You know, things are going to be good.
- 11:09I'm not going to worry about it. That's because I got roll bar integrated with all the talk Python
- 11:12stuff, which is really cool. So if there's a problem, you know, I can just read what the error
- 11:16is and probably fix it pretty easily. So all the Python byte listeners, they can have the same
- 11:20peace of mind. They just have to go to rollbar.com slash Python bytes and sign up for the free tier.
- 11:24Sounds cool, huh?
- 11:25Sounds very good.
- 11:26Yeah. Yeah. It's good. It's good to be on vacation and you'll not worry about things working. Just
- 11:31set up the error notifications and you're all good. I'm really excited that there's a new version of
- 11:37Python. I'm, I think people are starting to move on from legacy Python and there's just end of this
- 11:42week. There's going to be one more reason to do so. So we actually have as our next item, a video,
- 11:48a conference presentation at PyCon Canada, 2016 by Brett Cannon. He did a talk called what's new in
- 11:55Python three. And I think it's interesting. You look at all the peps and all the stuff that's coming
- 12:01and you think, well, okay, they're doing little tweaks here. I guess it has new string formatting,
- 12:04whatever. It turns out there are over 16 peps in Python three six. And that's more than any peps
- 12:11that have been in Python three other than the actual creation of Python 3.0 itself. That's pretty cool,
- 12:16right?
- 12:17Maybe we should have had another role before now then maybe, but I'm excited for all of these.
- 12:22Yeah. It's going to be great. It's going to be great. The reason I like this video and I want to
- 12:26point it out is we could all go to, you know, what's new in Python three and we can read the list.
- 12:32Like, okay, well here dictionaries will be ordered. there's now a private identifier or like a
- 12:37versioning number on dictionaries. Like, okay, whatever, who cares? This gives you the story
- 12:41behind all the changes coming to Python three six, right? Why did the core developers of which Brett
- 12:47is one think that this is a good idea? Like, how does it help? What, what really problem,
- 12:52what problem are they really trying to solve deep down when they made this change? And it really is
- 12:57a cool look inside what's coming with Python three six. that sounds great.
- 13:02I think it's, it's good. So Python three six release candidates available right now if you want to
- 13:07download it, but you know, if you can wait like five days, you should have the final version of Python
- 13:11three six. They did something with virtual environments, right?
- 13:14Yeah. This is one of the things I was stumbled across. I think it was in a Reddit line somewhere.
- 13:19The command command line command of pyvenv, which I can't remember which version that came in on one
- 13:26of the three O's that's being deprecated. And the reason, and they want people to use the dash
- 13:32M V E N V instead. And that's so that you specifically tell the virtual environment system,
- 13:40which Python to use. And it makes the programmer know, need to know how to get to Python first before
- 13:47they create a virtual environment. I think that it totally makes sense. It's just something to point
- 13:52out. I think it's important. It, I'm going to have to actually edit my book because of this,
- 13:57because, I think I recommended pyvenv in mine. So time to un-recommend it.
- 14:03Yeah. That's cool. No, I do think it is good. I mean,
- 14:06you can say Python three --version. You'll see what that is. And then you can say
- 14:10Python three dash M V and V, and then that's the thing you're going to get. Right. So it is a little
- 14:14more clear, I guess. Very cool. Yeah. It wouldn't be a week in Python without some form of testing or
- 14:20code coverage, right? Yeah, definitely. And, Ned Batchelder, who we all owe some gratitude for,
- 14:26for coming up with, or for taking over the coverage package. He's, I interviewed him,
- 14:32about that on episode 12 of testing code, but, he's planning a new feature for coverage up high,
- 14:38um, which will tell us which, so when you, when you run a coverage report, also what functions
- 14:45caused this or how did you get this stuff covered? And, he covers it in an article. He taught,
- 14:51he titled, who tests what this is a discussion about kind of, how I like the discussion because
- 14:58those, those, those people new to coverage can kind of peek inside and see the different stages
- 15:03of how coverage works. It goes through measurement and storing the data and then combining the data
- 15:08and reporting because you can't have multiple tests, most multiple runs and combine them into,
- 15:14to one report. This idea of, trying to figure out which code was covered by which tests
- 15:20is how it started, but he comes up with some, some reasons why there may be more,
- 15:25more uses than just in testing. And it's a, it's a good discussion, but part of one of the things he,
- 15:32why he wrote this article is, is to try to get some help. He wants some feedback.
- 15:36So some of the questions are, he discusses the memory, memory usage and, and the data model.
- 15:42And he wants to know if there's something we need more sophisticated problem solving on this,
- 15:48or should we be more conservative with memory? And then the output, the output right now is intended
- 15:53to be in Jason, but he wants to know if somebody could use a different data format. I like the
- 15:59direction he's going with it. And I think I'll use it. And I encourage anybody that has sort of a
- 16:04non-standard usage of coverage to take a look at this article and give Ned some feedback.
- 16:08Yeah. I really like it as well, because a lot of times, unless you're actually a contributor to the
- 16:13project already, you feel like the fate of the thing has already determined, but this was much more like,
- 16:19look, we have this challenging problem. these are the ways and the trade-offs were
- 16:23thinking about the ways we're thinking about solving it. The trade-offs were contemplating.
- 16:26We're not sure where to go. If you want to help, here's how to help. If you want to give us feedback
- 16:31before we jump in and go the wrong direction, do it. So this is a really cool article just on philosophy
- 16:36as well.
- 16:37Yeah. I think it's great.
- 16:38And being able to know which tests actually triggered the covered line when you run a thousand
- 16:43tests. Well, with these three, like, that's pretty interesting.
- 16:46Yeah. And you know, before I talked to him, I didn't realize that there was,
- 16:49there were so many features of coverage that I didn't realize, like being able to have multiple
- 16:53test runs and combine that data and HTML output and things like that. It's pretty cool.
- 16:58Yeah. Yeah. Quite cool. Quite cool.
- 16:59So what do you got for us, Michael?
- 17:01All right. I got one, one final glorious topic for the rest of the year to round out 2016. So
- 17:07here it is. Threaded asynchronous magic and how to wield it. So this is a really cool article by
- 17:14Christian Medina. You know, we had talked about the, I don't remember exactly the title,
- 17:19but that asyncio tutorial that was like the G event tutorial remade for asyncio and Python 3.4.
- 17:26And we're like, well, wouldn't it be cool if there's a great one on async and await, like the really,
- 17:30the truly new cool features of Python for threading and parallelism. Well, Christian Medina wrote it.
- 17:37Awesome.
- 17:38He wrote a really nice one and it has a bunch of bite-sized examples. You can, you know,
- 17:43they're not too, they're not too large, but they don't seem entirely fake. So he has one example of
- 17:48like sending email notifications, sort of asynchronously, but it's like, you know, but you
- 17:54realize there's no awaitable asynchronous, like way to send mail in Python. So, well, we're just going to
- 17:59block, but at least we can use this asyncio loop for that. That's cool. And then also talked about the
- 18:04aiohttp library, which is an HTTP client server for asyncio and how to do a bunch of parallel web
- 18:12requests. So we often think about requests being the primary way that we do programming against web
- 18:19services and generally HTTP, but this is another option that's really simple that fits exactly into
- 18:25the asyncio. So you can easily block on the network calls, which will then free up the thread to go do
- 18:31other stuff because it knows it's waiting on the network. That sounds cool. Yeah.
- 18:34Yeah. It's really cool. It covers things like tasks, scheduling tasks, scatter, gather styles of
- 18:39programming, and then even moving the asyncio loop to a background thread. So you don't block up your
- 18:44main thread, but you kind of have a place to put all the asynchronous work and let it run on that other
- 18:48one thread, which is pretty cool. So yeah. So thanks Christian for doing that. Got to meet him at
- 18:54PyCon last year. And so that was fun. And hopefully everyone else is going to PyCon. If you don't have
- 19:00your tickets yet, you need to be getting it right, Brian. Definitely. I missed out last year. So
- 19:05don't be sad. Get tickets before they sell out because this I'm sure it will sell out. It sold
- 19:10out early last year. And plus it's in Portland and Portland rocks. Portland definitely rocks. It's
- 19:15going to be weird. They're going to be keeping it weird. All right. Well, that's it for me. I don't
- 19:21really have a whole lot of news to share other than just saying thanks to everyone for listening,
- 19:24you know, for our new podcast. It's been fun to do for you and I appreciate all the feedback.
- 19:29I appreciate it too. Speaking of feedback, we did get one person. I think it's Harry J. I hope I
- 19:36didn't pronounce that wrong on Twitter said that he listened to episode three and I had mentioned that
- 19:42a library called Pianini that don't know if I'm pronouncing that right, but I assumed that these were
- 19:48that maybe it was named after the Knights who say knee. We thought that would be fun anyway. Yeah,
- 19:53definitely. But Harry J. tells me that this is not true. It's named after a Sanskrit grammarian
- 20:01with a P-A. I don't know how to pronounce that either. It's P-A-N-I-N-I. Anyway, thanks. I like
- 20:07fact checking. Yeah, it's great to have fact checkers. Awesome. I'm still going to call it Pianini.
- 20:11Knee, knee, knee. Yeah, definitely. Just know it has a different origin. Okay. Well, thank you,
- 20:19Brian. Thank you everyone for listening. Thank you, Royal Bar for sponsoring the show. We will
- 20:23see you all in January. Until then, you know, enjoy the winter wonderland unless you're down
- 20:28in Australia, then have a nice summer. Yeah, definitely. See you next year.
- 20:32Yeah. See you next year. Bye everyone. Bye.
- 20:34Thank you for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's
- 20:39Python Bytes as in B-Y-T-E-S. And get the full show notes at pythonbytes.fm. If you have a news item
- 20:46you want featured, just visit pythonbytes.fm and send it our way. We're always on the lookout for
- 20:51sharing something cool. On behalf of myself and Brian Okken, this is Michael Kennedy. Thank you for
- 20:56listening and sharing this podcast with your friends and colleagues.