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


Transcript #14: Lots of Python style and Python 3000 is 3000 days old

Return to episode page view on github
Recorded on Tuesday, Feb 21, 2017.

00:00 This is Python Bytes, Python news and headlines delivered directly to your earbuds.

00:05 This is February 21st, 2017.

00:09 I'm Michael Kennedy here with my co-host Brian Okken.

00:12 Hey Brian, how's it going man?

00:13 Going great.

00:14 We have some really cool stuff to talk about.

00:16 As usual, the Python ecosystem is bursting with good things to discuss.

00:21 Yeah, definitely is.

00:22 So let's start with like a little reference book that we can use to stay on top of Python And specifically, modern Python, Python 3.

00:30 Yeah, so Matt Harrison has self-published quite a few books already.

00:35 And this one, I assume he self-published this one, but it's a tiny Python 3.6 notebook.

00:41 And he released it on GitHub, and he also has a physical copy for sale on Amazon.

00:49 Anyway, I guess I'll just quote his introduction.

00:53 He said, "This is not so much as an instructional manual, but rather notes, tables, and examples for Python syntax.

01:00 And I think it's pretty awesome.

01:02 It's like all of the syntax and everything boiled down into just the fax man sort of thing.

01:11 It's like the pocket Python reference that you need, right?

01:13 Yeah, and I like it even online, but it's one big long file.

01:19 I think he's got it priced at less than $10.

01:23 So I'm going to give it a shot and try the physical copy because I think that might be kind of a nice thing to have around.

01:28 Yeah, yeah. Do you know if there's an e-book version?

01:30 I think, yeah, I think there is an e-book version.

01:32 Sweet, sweet, sweet. My whole library lives on my Kindle. If it's not on my Kindle, I don't know about it. I love physical books, but I've done so much traveling for work that I just, I'm like, I can't take three books on this trip. I'm just going to put them on my Kindle, you know?

01:46 So, very cool.

01:47 And I know he does a lot of training and he said that he wrote this partly as something to give away at his, when he does training.

01:54 And I think that's kind of a nice thing to hand people if you're gonna do training is something like this.

02:00 - Yeah, absolutely.

02:01 It's a perfect follow on to a training course or online course or something.

02:05 Okay, cool.

02:06 So the next one is by a friend of the show, Anthony Shaw.

02:10 And title is, "Oh no, this package is only Python 2." Or only supports Python 2.

02:16 The idea is like, if you're like plowing through a project, doing some Python work and you hit a package that's not supported because it's only Python 2, he wrote up a nice little guide of how to solve that problem and maybe solve it for the world and not just for yourself.

02:30 He has a 7.5 step guide here.

02:35 First of all, check that nobody else has solved it.

02:37 An example of this might be if you go to, say, suds and check out the suds package, which is like a SOAP client for Python, it's only Python 2.

02:46 It was updated five years ago.

02:48 You could be like, "Oh no, this doesn't work." Well, there's another one someone else forked and created called suds-jerko.

02:55 And that one is the Python two and three version.

02:58 So be sure to look around and like don't go through this effort if someone else is like a non not very popular but solved version.

03:05 So then he says, Alright, what you can do is you fork it first, like go and see if there's print statements that are statements and not functions.

03:12 Fix that, right?

03:13 Write some tests, hopefully tests exist.

03:15 But if they don't write some tests, because you know, just the fact that it runs isn't really good enough and has some cool package he mentions called modernize.

03:23 Do you know this package, Brian?

03:24 I haven't used it, but I've heard of it.

03:25 Yeah, this is not like modernizer from JavaScript.

03:28 This is something from Python to aid with the conversion.

03:32 So yeah, it's very cool.

03:33 I haven't used it much myself either, but I'm going to check it out.

03:35 So thanks, Anthony, for pointing that one out.

03:37 It says, all right, update the setup UI to describe your new dependencies and stuff, install into your original project, raise a pull request.

03:45 And then sadly says, okay, well, what happens when three months later, your pull request is ignored?

03:50 How do you go about dealing with this?

03:52 And it turns out as a result of this article, the package that he he wrote this article, because this happened to him, he's like, Alright, I need this package.

04:00 And oh, no, it's not supported on Python three.

04:02 So he went through this and actually did the PR and said, after he wrote this article, the author or maintainer of that package came along and quickly accepted the PR.

04:12 And now that thing is Python three.

04:14 Okay, so does he have any recommendations for what happens if nothing happens?

04:19 If nothing happens, he says, after a while, you know, you probably should do what the guy the Jerko guy, that's his first name, Jerko did with suds is go and modify the setup py, create a different package name, and just submit it to pypi as like an alternate version or something if no one's gonna fix the old one, and you can't get control over it.

04:41 Yeah, interesting.

04:42 - Yeah, it's worth pointing out that the PyPA, the packaging authority group, they actually just, I think we maybe even discussed this on the show earlier in other episodes, is that they came up with a way to deal with this.

04:57 Like SUDS is five years old.

04:59 It's not been edited in five years.

05:02 Like surely that should be replaced by a modern version of it if there is one, right?

05:06 So that's cool.

05:07 Yeah, I think we talked about it last time, right?

05:08 - Yeah, and it should be, and I'm glad they're taking that on because there should be a way to say, hey, I'm willing to be the new maintainer if nobody else wants this.

05:16 - Absolutely.

05:17 - Nice article and I like that this was discussed because that happens, I think that happens at least fairly regularly.

05:26 - Well, and instead of just throwing up your hands, if a few people go through these steps on the popular packages, right, that solves it for the world.

05:33 It doesn't just, it solves it for the whole community.

05:35 It doesn't just solve it for your project, so that's great.

05:37 - Yeah, definitely.

05:38 And I think that maybe modernize might be a topic for some other week.

05:43 - Yeah, absolutely.

05:44 - Next we've got another, I guess another book-like thing.

05:47 It's not really a book, but there's somebody named Andrew Montalenti, why do I try to pronounce names?

05:56 Anyway, it's a article called "Elements of Python Style" and of course playing on the elements of, is it just elements of style?

06:04 Anyway, from writing, but anyway, it takes, it's supposed to be more than PEP 8 and it's an opinionated little fairly small style guide still.

06:16 It's not very huge, talking about basically some common good way to style.

06:22 I just like the format of it.

06:24 And I think that I was going to take this article, and it's on GitHub.

06:27 I was going to take it and fork it and try to make something for my own team.

06:31 Oh, yeah, that's cool.

06:32 I think these things are great.

06:33 And certainly having a consistent style helps, like you say, for example, on your team.

06:39 And if you are, a lot of people listen to the show, they're looking for jobs, getting into programming, getting into Python, like, study this kind of stuff, right?

06:46 If you show up for like an interview and they ask you to write some code and you write it JavaScript style, or you write it C++ style and you claim to know Python, they're gonna look at you sideways and go, "Hmm, not so sure about that," you know?

06:57 - Yeah.

06:58 - So knowing these things is like the first step to fitting in, I guess.

07:03 - You have one course on Pythonic stuff, so what did you think of all of these recommendations here?

07:08 I think these were really good.

07:10 I didn't totally study every single one of them, but looking through it, it looked really good.

07:14 For example, one of the pieces of guidance I really like says you can choose camel case, so capital first letter, capital letters of every word for things that are not quite class-like.

07:27 If you have a class, PEP 8 says that should be camel case.

07:31 But you also have other things like, what about named tuples?

07:35 How should a named tuple be?

07:36 I mean, it's effectively a class that has no functions, just data.

07:41 But you know, it seems like that.

07:42 So guidance like that, like he says, the main benefit of camel case is calling attention to something that's a global noun rather than a local label or a verb.

07:51 And like, for example, Python uses true, false, and none as camel case, even though they're not classes.

07:56 So yeah, I think this is great.

07:57 I enjoyed the article.

07:59 My next item for you is just a cool bit of trivia.

08:03 I want to say thank you to Christian Klaus for sending this my way.

08:07 And I found, I was looking through Reddit for things for this episode and came across somebody had posted a tweet of mine, which that's never happened to me before that a tweet has been actually a topic on Reddit.

08:20 And one of this popularity, it had 537 upvotes and 71 comments on my tweet.

08:26 Anyway, why was that cool?

08:27 Why is that interesting?

08:28 It has nothing to do with me because I just carried the message from Klaus basically.

08:32 And it says Python 3, which was originally called Python 3000.

08:37 Right?

08:38 That's it's actually from PEP 3000 is the original working title that it got.

08:43 And it was released December 3, 2008.

08:47 So last Sunday, February 19, it was exactly 3000 days old.

08:52 Oh, cool.

08:53 Isn't that nice?

08:54 So we've come a long ways with Python 3.

08:57 And you know, some people kind of treat it like it's new.

09:00 It's not new.

09:01 Definitely not.

09:02 Definitely not.

09:03 But I think it's really cool that we just passed the day where Python 3000 is 3000 days old.

09:08 Actually, that's worthwhile trivia.

09:09 I like it.

09:10 Yeah, thanks.

09:11 So another thing that I really like is these resources or like sites that bring all these different information together.

09:18 Because I have people that ask me all the time, "Hey, Michael, I want to get started in programming.

09:22 What are the steps I should take?" or "I've gotten this far in Python.

09:25 What should I study next?

09:26 Should I go into databases?

09:27 Should I go into data science?

09:29 What else should I do?" Right?

09:31 A couple guys that are putting together, actually they're putting together some interesting topics lately. Bob Bilderbos and Julian Sequeira, I should have you do the names. These are pretty interesting guys that have actually talked to us, sent out feedback to us about the show and other things. But they put together a post called, that it's Python resources and it's called Python books, videos, and resources from beginner to pro.

10:00 We're going to link a Reddit thread that they put up and also the link to their post.

10:04 But it's actually, it's not huge.

10:07 That's one of the things I like about it.

10:08 It's not really big list, but it's one of the things that it definitely has is it has some nice podcasts listed in the other resources.

10:16 Yeah, of course.

10:17 Of course.

10:18 It has like a nice getting started section.

10:20 It has a now you've done fundamentals, how do you get better, additional resources, all sorts of stuff.

10:27 So a lot of different ways, you know, it's got like a Hitchhiker's Guide to Python, Fluent Python, Effective Python, a lot of stuff that I've covered on my podcast, which is really great.

10:36 Some online courses and thank you, they've included mine in there, which is really cool.

10:39 But yeah, a bunch of stuff in here that you can check out.

10:42 Fullstack Python, which of course is excellent.

10:45 Their website is pybit.es, which is fairly clever and fairly similar to the name of our podcast.

10:54 It is quite similar.

10:55 It's not the same, but it is quite similar, PyBytes.

11:00 These guys, at least Bob is in Spain, I think.

11:03 So the ES makes a lot of sense there.

11:05 It's very cool.

11:06 All right, my last one is a Python tool that I think a lot of people will find very useful.

11:12 So it's called Mongo Audit, and it's written in Python, and it has even a nice little GUI to it, which is pretty cool.

11:18 So it describes itself as a CLI, or command line interface tool for auditing MongoDB servers, poor security settings and performing automatic or automated penetration testing.

11:30 So you can just pip install Mongo audit and then run it against your Mongo servers.

11:34 All databases, you want them to be secure, right?

11:37 Like if database is just accessible on the internet with no login, that's bad, right?

11:41 Yeah, especially if you have private stuff.

11:45 So I love MongoDB.

11:47 I'm on the MongoDB masters group.

11:50 And I've worked with MongoDB for a long, long time.

11:52 There's a couple of choices that MongoDB has made in the early days that have kind of harmed it in terms of getting it in the headlines in ways in which it shouldn't be.

12:02 And a couple of those are by default runs without authentication.

12:06 Of course, you can set a username and password.

12:08 But if you don't take that action, because you don't know better, well, then, if it's listening on the open internet, that's really, really bad.

12:15 And so there's a number of things like make sure you run with SSL enabled, make sure you run with the authentication, and so on and so on.

12:21 So this tool basically go and run all those tests against a set of MongoDB servers, right?

12:27 And it checks that it's running like, say, on a non-default port.

12:31 It only accepts connections from certain hosts and so on.

12:34 So this is really, really cool.

12:36 This is very cool.

12:37 And I'm putting together a tutorial with using Mongo and I'm not, haven't taken any classes in it and I don't know how to do any of this stuff.

12:45 So I'm glad that there's a tool like this that can point out what problems I've had with my setup and maybe I can pick your brains as to what I should do next.

12:54 Yeah, yeah, absolutely.

12:55 I would say like at a minimum, you know, run this tool and it has a lot of great recommendations.

13:01 But certainly at a minimum, if you're, you know, make sure you're at least only listening on local loopback.

13:06 So 127.0.0.1 or you have SSL enabled and authentication enabled, right?

13:11 Like those are the two big ones, but this tool will catch like that and lots and lots more.

13:16 If you're somehow in charge of MongoDB things, pip install mongo audit and have a run at it.

13:24 Very cool.

13:24 Yeah, very cool. All right, that's it for the news this week.

13:27 Brian, anything else you want to share with everyone?

13:29 How's the book coming along?

13:31 You know, it's very exciting.

13:32 I think we're going to do a total of, I can't remember, seven or eight chapters and I've got five that I've already gone through second phase editing, and we're playing with book titles and playing with covers now.

13:45 So hopefully not too much longer before we can make an announcement.

13:49 - How awesome, and who's the publisher?

13:50 - Pragmatic.

13:51 - Pragmatic, awesome.

13:52 Do they do things like have special covers?

13:54 Do they have like characters in the covers or anything?

13:56 - There are different pictures of course for every book, but we're working with, I'm trying to convince them to not do another snake cover just because it's Python.

14:05 - Absolutely, no more snakes.

14:06 We can do more.

14:07 It's not even as, what's so funny is like, it's not even a snake as the origin, right?

14:11 It's Monty Python.

14:12 - I was thinking maybe a large tree, but that might not go over well.

14:17 - What about the rabbit, you know, the rabbit with the grenades?

14:19 - Oh yeah, that'd be fun.

14:21 - The killer rabbit.

14:22 - Killer rabbit.

14:23 Maybe it won't sell too many tech books.

14:25 I think it'd be funny.

14:27 Well, you have some news, Michael.

14:29 - I do, just this morning I released my latest course at bit.ly, so bit.ly/python-rest-course.

14:38 So I created a course that is consuming HTTP in RESTful services, JSON, XML, SOAP, binary data, screen scraping, all that kind of stuff.

14:47 So if that's interesting to you, check out this course.

14:49 And the next one I'm working on is the anti-matter version of this course, creating services so that other people can consume them.

14:58 - Oh, nice. - Yeah.

14:59 So I'm kind of on a services trip these last few weeks.

15:01 - Cool. - Yeah, yeah.

15:02 All right, well, thanks for getting together today, Brian, and talking about all this stuff.

15:07 - Yeah, thank you. - Very interesting stuff.

15:08 I love all the books and the references and the guidance.

15:11 >> Yeah.

15:12 >> All right.

15:13 Catch you later.

15:14 Bye, everyone.

15:15 >> Bye.

15:16 >> Thank you for listening to Python Bytes.

15:17 Follow the show on Twitter via @PythonBytes.

15:19 That's Python Bytes as in B-Y-T-E-S.

15:22 And get the full show notes at PythonBytes.fm.

15:25 If you have a news item you want featured, just visit PythonBytes.fm and send it our way.

15:30 We're always on the lookout for sharing something cool.

15:32 On behalf of myself and Brian Aukin, this is Michael Kennedy.

15:36 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page