Brought to you by DigitalOcean - grab your $10 credit and deploy your first project for free


« Return to show page

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

Recorded on Tuesday, Feb 21, 2017.

Python Bytes Transcript

Episode #14: Lots of Python Style and Python 3000 is 3000 Days Old

Michael KENNEDY: This is Python Bytes, Python news and headlines delivered directly to your earbuds. This is February 21, 2017. I’m Michael Kennedy, here with my co-host, Brian Okken.

Hey, Brian. How’s is going, man?

Brian OKKEN: Going great.

KENNEDY: We have some really cool stuff to talk about as usual, the Python ecosystem is bursting with things to discuss.

OKKEN: Yeah, it definitely is.

KENNEDY: So, lets’ start with a little reference book that we can use to stay on top of Python, specifically modern Python, Python 3.x.

OKKEN: Matt Harrison has self-published quite a few books already. And this one – I assume he self-published this one – is a tiny Python 3.6 notebook. He released it on GitHub and he also has a physical copy for sale on Amazon. I guess I’ll just quote his introduction:

“This is not so much an instructional manual, but rather notes, tables and examples for Python syntax.”

I think it’s pretty awesome. It’s all the syntax and everything boiled down into, ‘Just the facts, ma’am’ sort of thing.

KENNEDY: It’s like the pocket Python reference that you need, right?

OKKEN: Yeah, and I like it even online, but it’s one big file. I think he’s got it priced less than $10. I’m going to give it a shot and try the physical copy. I think that might be kind of a nice thing to have around.

KENNEDY: Do you know if there is an e-book version?

OKKEN: Yeah, I think there is an e-book version.

KENNEDY: 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 travelling for work that, I’m like, ‘I can’t take 3 books on this trip. I’m just going to put them on my Kindle.’ So, very cool.

OKKEN: I know he does a lot of training and he said that he wrote this partly as something to give away when he does training. That’s kind of a nice thing to hand people, if you’re going to do training, is something like this.

KENNEDY: Absolutely. It’s the perfect follow-on to a training course or online course.

The next one is by friend of the show, Anthony Shaw. The title is, “Oh No! This Package is Python 2 Only.” The idea is like if you’re plowing through a project of 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 solved that problem, and maybe solve it for the world and not just for yourself. He has a 7.5 step guide here.

First of all, check that nobody else has solved it. An example of this night be, if you go to Suds and check out the Suds package, which is like a soap client for Python. It’s only Python 2.x updated 5 years ago, and you could be like, ‘Oh, no. This doesn’t work.’ Well, there’s another one someone else forked and created called Suds-jerko and that one is the Python 2.x and 3.x version. So, be sure to look around and don’t go through this effort if someone else has done a not very popular but solved version.

Then he says, ‘Alright, what you’re going to do is fork it then go and see if there’s print statements that are statements and not functions. Fix that. Write some tests. Hopefully, tests exist but if they don’t write some because just the fact that it runs isn’t really good enough.’

A cool package he mentions is called Modernize. Do you know this package, Brian?

OKKEN: I haven’t used it but I’ve heard of it.

KENNEDY: This is not like Modernizer from JavaScript, this is something from Python Aid with the conversion. Yeah, it’s very cool. I haven’t used it much myself either but I’m going to check it out, so thanks, Anthony, or pointing that one out.

So, Update setup.py to describe your new dependencies and stuff. Install into your original project, raise a pull request. And then sadly, he says, ‘What happens 3 months later when your pull request (P.R.) is ignored?’ He wrote this article because this happened to him. He’s like, ‘Alright, I need this package. Oh, no, it’s not supported on Python 3.x.’ So, he went through this and actually did the P.R. After he wrote this article, the author or maintainer of that package came along and quickly accepted a P.R. and now that thing is Python 3.x.

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

KENNEDY: If nothing happens, he says after a while you probably should do what the jerko guy, that’s his first name, did with Suds. Go in and modify the setup.py, create a different package name and just submit it to PyPI like an alternate version of something, if no one is going to fix the old one and you can get control over it.

OKKEN: Interesting.

KENNEDY: It’s worth pointing out that the PyPI, the PyPA – the Packaging Authority group – they actually just, I think we may have even discussed this on the show in earlier episodes, they came up with a way to deal with this. Suds is 5 years old. It’s not been edited in 5 years. Surely, that should be replaced with a modern version of it if there is one. So, that’s cool. I think we talked about it last time.

OKKEN: Yeah, and it should be and I’m glad they’re taking that on. There should be a way to say, ‘Hey, I’m willing to be the new maintainer if nobody else wants this.

KENNEDY: Absolutely.

OKKEN: It’s a nice article and I like that this was discussed because I think that happens fairly regularly.

KENNEDY: Well, 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. It solves it for the whole community, it doesn’t just solve it for your project, so that’s great.

OKKEN: Yeah, definitely. And I think that maybe Modernize will be a topic for some other week.

KENNEDY: Yeah, absolutely.

OKKEN: Next we’ve got another book-like thing. It’s not really a but there’s somebody names Andrew Montalenti. It’s an article called, “Elements of Python Style” playing, of course, on “The Elements of Style” from writing. It’s supposed to be more than PEP 8 and it’s an opinionated, fairly small style guide still. It’s not very huge, talking about, basically, a good way to style. I just like the format of it. I think that I was going to take this article – it’s on GitHub – and fork it and make something for my own team.

KENNEDY: Yeah, that’s cool. I think these things are great. Certainly, having a consistent style helps, say for example, on your team. A lot of people listen to this show looking for jobs, getting into programming and getting into Python. Study this kind of stuff. If you show up for 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 going to look at you sideways and go, ‘Hmm, I’m not so sure about that.’ So, knowing these things is the first step to fitting in, I guess.

OKKEN: You have one course on Pythonic stuff so what did you think of all of these recommendations here?

KENNEDY: I think these were really good. I didn’t totally study every single one of them but looking through it, it looked really good. For example, one of the pieces of guidance that I really liked says, ‘You can choose CamelCase, so capital letters of every word for things that are not quite class-like. If you have a class, PEP 8 says that should be CamelCase. But you also have other things like: What about named tuples? How should a named tuple be? It’s effectively a class that has no functions, just data but it seems like it. Guidance like that. He says:

“The main benefit of CamelCase is calling attention to something as a ‘global noun’ rather than a local label of verb. Notice that Python uses True, False and None use CamelCase even though they are not classes.”

So, yeah, I think this is great. I rather enjoyed the article

My next item for you is just a cool bit of trivia. I want to say thank you to Christian Clauss (@cclauss) for sending this my way. I was looking through Reddit for things for this episode, and came across somebody had posted a tweet of mine. That’s never happened to me before that a tweet of mine has been a topic on Reddit and one of this popularity. It had 537 up votes and 71 comments on my tweet.

Why is that cool? Why is that interesting? It has nothing to do with me. I just carried the message from Clauss. He says, ‘Python 3.x, which was originally called, Python 3000, it’s actually from PEP 3000, the original title. It was released December 3rd, 2008. So, last Sunday, February 19th, it was exactly 3,000 days old.’

OKKEN: Oh, cool.

KENNEDY: Isn’t that nice? So, we’ve come a long ways with Python 3.x and some people treat it like it’s new; it’s not new.

OKKEN: No, definitely not.

KENNEDY: But I think it’s really cool where we just passed the day where Python 3000 is 3,000 days old.

OKKEN: Actually, that’s worthwhile trivia. I like it.

KENNEDY: Another thing I really like is these resources or sites that bring all this information together. People ask me all the time, ‘Hey, Michael. I want to get started in programming. What are the steps I should take?’ or ‘I’ve gotten this far in Python, what should I study next? Should I go in databases? Should I go into data science? What else should I do?’

OKKEN: Yeah, so there’s a couple guys that are putting together some interesting topics lately. Bob Belderbos and Julian Sequeira, these are pretty interesting guys that have sent our feedback to us about the show and other things. They put together a post called, “From Beginner to Pro: Python Books, Videos and Resources.” We’re going to link a Reddit thread that they put up so it will link to their post. Actually, it’s not huge. That’s one of the things I like about it. It’s not a really big list, but it’s one of the things that is has is some nice podcasts listed in the “Other Resources.”

KENNEDY: Yeah, of course. It had a nice “Getting Started” section. It has a “Now that you’ve done fundamentals, how do you get better?” “Additional Resources.” All sorts of stuff. It’s got “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. Some online courses and thank you, they’ve included mine in there, which is really cool. But yeah, a bunch of stuff that you can check out. Full-Stack Python, which, of course, is excellent.

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

KENNEDY: It is quite similar. It’s not the same but it is quite similar. These guys, Bob is in Spain I think, so it makes a lot of sense there. Very cool.

My last one is a Python tool that I think a lot of people will find very useful. It’s called MongoAudit. It’s written in Python and it has even a nice little GUI to it. It describes itself as a CLI command line interface tool auditing MongoDB servers, detecting poor security settings and performing automated penetration testing. You can pip install MongoAudit and then run it against your servers. All databases, you want them to be secure, right? A database that is just accessible on the internet with no login, that’s bad, right? Yeah. Especially if you have private stuff in it.

I love MongoDB, I’m in the MongoDB Masters group and I’ve worked with MondoDB for a long time. There’s a couple of choices that Mongo DB has made in the early days that have kind of harmed it, in terms of getting it in the headlines in ways it shouldn’t be. A couple of those are by default runs without authentication instead of using a password. But if you don’t take that action because you don’t know better, then if it’s listening on the open internet that’s really bad. There’s a number of things like, ‘Make sure you run with SSL’ and ‘Make sure you run with authentication’ and so on. This tool will basically go and run all those tests against a set of MongoDB servers. It checks that it’s running on a non-default port. It only accepts connections from certain hosts and so on. So, this is really cool

OKKEN: This is very cool. I’m putting together a tutorial on using Mongo. I haven’t taken any classes in and I don’t know how to do any of this stuff. I’m glad that there is a tool like this so they can point out what I’ve had with my set-up and maybe I can pick your brain as to what I should do next.

KENNEDY: Absolutely. I would say, at a minimum, run this tool. It has a lot of great recommendations. But certainly, at a minimum, make sure you’re only listening on local loopback, 127.0.0.1. Or you have SSL enabled and authentication enabled. Those are the 2 big ones. But this tool will catch lots more.

If you’re somehow in charge of MongoDB things, pip install MongoAudit and have a run at it.

OKKEN: Very cool.

KENNEDY: Alright, that’s it for the news this week. Brian, anything else you want to share with everyone? How’s the book coming along?

OKKEN: It’s very exciting. I think we’re going to do a total of 7 or 8 chapters and 5 have already gone through second phase editing. We’re playing with book titles and playing with covers now. Hopefully not too much longer before we can make an announcement.

KENNEDY: Awesome. How’s the publisher?

OKKEN: Pragmatic.

KENNEDY: Awesome. Do they have special covers or do they have characters on the covers?

OKKEN: There are different pictures, of course, for every book. But I’m trying to convince them to not do another snake cover, just because it’s Python.

KENNEDY: Absolutely. No more snakes. We can do more! It’s not even a snake as the origin, it’s Monty Python.

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

KENNEDY: What about the rabbit with the grenades?

OKKEN: Oh, yeah. That’d be funny.

KENNEDY: The killer rabbit. (Laughing) Maybe it won’t sell any tech books but I think it will be funny.

OKKEN: You have some news, Michael.

KENNEDY: I do. Just this morning I released my latest course at bit.ly/python-rest-course. I created a course that is “Consuming HTTP and RESTful services.” JSON, XML, Soap, binary data, screen scraping, all that kind of stuff. If that’s interesting to you, check out this course. The next one I’m working on is the anti-matter version of this course, creating services so people can consume them. I’m on a services trip these last few weeks.

OKKEN: Cool.

KENNEDY: Alright. Well, thanks for getting together today, Brian, and talking about all this stuff. Very interesting stuff. I love all the books and the references and the guidance.

Catch you later. Bye, everyone.

OKKEN: Bye.

KENNEDY: Thank you for listening to Python Bytes. Follow the show on Twitter via @pythonbytes and get the full show notes at pythonbytes.fm. If you have a news item you want featured, just visit pythonbyes.fm and send it our way. We’re always on the lookout for sharing something cool. On behalf of myself and Brian Okken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page