Python Bytes - #14 Lots of Python style and Python 3000 is 3000 days old
Episode Date: February 22, 2017Topics covered in this episode: Tiny Python 3.6 Notebook - Matt Harrison Oh no! This package is Python 2 only - Anthony Shaw Elements of Python Style - Andrew Montalenti Python 3 was exactly 3000 d...ays old this past Sunday mongoaudit Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/14
Transcript
Discussion (0)
This is Python Bytes, Python news and headlines delivered directly to your earbuds.
This is February 21st, 2017.
I'm Michael Kennedy here with my co-host, Brian Aukin.
Hey, Brian, how's it going, man?
Going great.
We have some really cool stuff to talk about.
As usual, the Python ecosystem is bursting with good things to discuss.
Yeah, it definitely is.
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.
Yeah. So Matt Harrison has self-published quite a few books already. And this one,
I assume he self-published this one, but it's a tiny Python 3.6 notebook. it's um he released it on github and he also has a physical copy for sale on amazon
anyway it's um i guess i'll just quote his introduction he said this is not so much as
an instructional manual but rather notes tables and examples for python syntax and i think it's
pretty awesome it's a it's like all of the syntax and everything boiled down into just the Faxman sort of thing.
It's like the Pocket Python reference that you need, right?
Yeah.
And I like it even online, but it's one big long file.
I think he's got it priced at less than $10.
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.
Yeah, yeah.
Do you know if there's an e-book version?
Yeah, I think there is an e-book version.
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? So very cool.
And 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. And I think that's kind of a nice thing to hand people if you're
going to do training is something like this. Yeah, absolutely. It's a perfect follow-on to
a training course or online course or something. Okay, the next one is by friend of the show anthony shaw and title is oh no this package is
only python 2 or only supports python 2 the idea is like if 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.
So he has a 7.5-step guide here.
So first of all, check that nobody else has solved it.
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. It was updated five years ago. five years ago you could be like oh no this doesn't work well there's another one someone
else forked and created called suds dash jerko and that one is the python 2 and 3 version 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.
So then he says, all right, what you're going to do is you're going to fork it.
First, go and see if there's print statements that are statements and not functions.
Fix that, right?
Write some tests.
Hopefully tests exist.
But if they don't, write some tests because just the fact that it runs isn't really good enough.
And it has a cool package he mentions called Modernize.
Do you know this package, Brian?
I haven't used it, but I've heard of it.
Yeah, this is not like Modernizer from JavaScript.
This is something from Python to aid with the conversion.
So yeah, it's very cool.
I haven't used it much myself either,
but I'm going to check it out.
So thanks, Anthony, for pointing that one out.
It says, all right, update the setup UI
to describe your new dependencies and stuff.
Install into your original project.
Raise a pull request.
And then sadly, it says, okay, well, what happens when three months later your pull request is ignored
how do you go about dealing with this 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 all right i need
this package and oh no it's not supported on python 3 so he went through this and actually did the pr and said after he wrote this article the the author or maintainer of that package came along
and quickly accepted the pr and now that thing is python 3 okay so does he have any recommendations
for what happens if nothing happens if nothing happens he says after a while you know you
probably should do what the guy the jerko guy that 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 going to fix the old one and you can't get control over it.
Yeah, interesting.
Okay. Yeah, it's worth pointing out that the PyPI,
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.
Like, SUDS is five years old.
It's not been edited in five years.
Like, surely that should be replaced
by a modern version of it if there is one, right?
So that's cool.
Yeah, I think we talked about it last time, right?
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.
Absolutely.
Nice article.
And I like that this was discussed because that happens, I think that happens at least fairly regularly.
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. It solves it for the whole
community. It doesn't just solve it for your project. So that's great.
Yeah, definitely. And I think that maybe modernize might be a topic for some other week.
Yeah, absolutely.
Next, we've got another,
I guess, another book-like thing. It's not really a book, but there's somebody named Andrew
Montalenti. Why do I try to pronounce names? Anyway, it's an article called Elements of Python
Style. And of course, playing on the elements of, is it just elements of style? 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. It's not very huge, talking about basically some common,
a good way to style. I just like the format of it. And I think that I was going to take this article and it's on GitHub.
I was going to take it and fork it and try to make something for my own team.
Oh yeah.
That's cool.
I think these things are great and it's certainly,
certainly having a consistent style helps.
Like you say,
for your example on your team.
And if you are,
a lot of people listen to the show,
they're looking for jobs,
getting into programming,
getting a Python,
like study this kind of stuff, right?
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 C++ style and you claim to know Python, they're going to look at you sideways and go, hmm, not so sure about that, you know?
Yeah.
So knowing these things is like the first step to fitting in, I guess.
You have one course on Pythonic stuff. So what
did you think of all of these recommendations here? I think these were really good. I didn't
totally study every single one of them, but looking through it, it looked really good.
Like for example, one of the pieces of guidance I really like says you can choose camel case. So
capital first letter, capital set, you know, capital letters of every word for things that are not quite class like right so yeah if you have a class pep 8 says that should be camel case but you also have other
things like what about named tuples how should a name tuple be i mean it's effectively a class
that has no functions just data but you know it seems like that 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
and like for example python uses true false and none as camel case even though they're not classes
so yeah i think this is great i enjoyed the article okay my next item for you is just a cool
bit of trivia and i want to say say thank you to Christian Klaus for sending
this my way. 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. And one of this popularity, it had 537 upvotes and 71 comments
on my tweet.
Anyway, why was that cool?
Why is that interesting?
It has nothing to do with me because I just carried the message from Klaus basically.
And he says, Python 3, which was originally called Python 3000, right?
It's actually from PEP 3000 is the original working title that it got.
And it was released December 3rd, 2008.
So last Sunday, February 19th,
it was exactly 3,000 days old.
Oh, cool.
Isn't that nice?
So we've come a long ways with Python 3
and some people kind of treat it like it's new.
It's not new.
No, definitely not.
Definitely not.
But I think it's really cool that we just passed the day where Python 3000 is 3000 days old.
Actually, that's worthwhile trivia.
I like it.
Yeah, thanks.
So another thing that I really like is these resources or sites that bring all these different information together.
Because I have people that 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 into databases?
Should I go into data science?
What else should I do, right?
Yeah, so there's a couple of guys that are putting together,
actually they're putting together some interesting topics lately.
Bob Belderboss and Julian Sequeria.
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.
We're going to link a Reddit thread that they put up and also the link to their post.
But it's actually,
it's not huge. That's one of the things I like about it. It's not really big list, but it's
one of the things that does definitely has is it has some nice podcasts listed in the other
resources. Yeah, of course. Of course. It has like 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.
So a lot of different ways.
You know, it's got like 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 in here that you can check out.
Full Stack Python, which of course is excellent. Their website is pybit.es, which is fairly clever and fairly similar to the name of our podcast.
It is quite similar. It's not the same, but it is quite similar, PyBytes. And yeah, these guys,
at least Bob is in Spain, I think. So the ES makes a lot of sense there.
That's very cool.
All right, my last one is a Python tool that I think a lot of people will find very useful.
So it's called Mongo Audit, and it's written in Python, and it has like even a nice little
GUI to it, which is pretty cool.
So it describes itself as a CLI or command line interface tool for auditing MongoDB servers,
detecting poor security settings
and performing automatic or automated penetration testing. So you can just pip install a Mongo audit
and then run it against your Mongo servers. All databases, you want them to be secure, right?
Like if a database is just accessible on the internet with no login, that's bad, right?
Yeah. Especially if you have private stuff in it. So I love MongoDB. I'm
on the MongoDB masters group and I've worked with MongoDB for a long, long time. 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. And a couple of those are by default runs
without authentication. Of course, you can set a username and password. 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. 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. So this tool basically go and run
all those tests against a set of MongoDB servers. right? And it checks that it's running like say on a non-default port.
It only accepts connections from certain hosts and so on. So this is really, really cool.
This is very cool. 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.
So I'm glad that there's a tool like this
so they 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.
Yeah, yeah, absolutely.
I would say like at a minimum,
run this tool and it has a lot of great recommendations.
But certainly at a minimum,
make sure you're at least only listening on local loopback. So 127.0.0.1, or you have SSL enabled and authentication enabled,
right? Like those are the two big ones, but this tool will catch like that and lots and lots more.
So if you're somehow in charge of MongoDB things, pip install Mongo audit and have a run at it.
Very cool.
Yeah. Very cool. Yeah, very cool.
All right, that's it for the news this week.
Brian, anything else you want to share with everyone?
How's the book coming along?
You know, it's very exciting.
I've got, 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 getting at with,
we're playing with book titles and playing with covers now.
So hopefully not too much longer before we can make an announcement.
How awesome. And who's the publisher?
Pragmatic.
Pragmatic. Awesome. Do they do things like have special covers? Do they have like
characters in the covers or anything?
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.
Absolutely.
No more snakes.
We can do more.
What's so funny is it's not even a snake as the origin, right?
It's Monty Python.
I was thinking maybe a larch tree, but that might not go over well.
What about the rabbit with the grenades?
Oh, yeah.
That'd be fun.
The killer rabbit.
Killer rabbit.
Maybe it won't sell too many tech books.
I think it'd be funny.
Well, you have some news, Michael.
I do.
Just this morning, I released my latest course at bit.ly,
so bit.ly slash python dash rest dash course.
So I created a course that is consuming HTTP and RESTful services,
JSON, XML, so binary data, screen scraping, all
that kind of stuff.
So if that's interesting to you, check out this course.
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.
Oh, nice.
Yeah.
So I'm kind of on a services trip these last few weeks.
Cool.
Yeah.
Yeah.
All right.
Well, thanks for getting together today, Brian, and talking about all this stuff.
Yeah.
Thank you.
Very interesting stuff.
I love all the books and the references and the guidance.
Yeah.
All right.
Catch you later.
Bye, everyone.
Bye.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at PythonBytes.fm.
If you have a news item you want featured, just visit pythonbytes.fm and send it our way. We're always on the lookout for
sharing something cool. On behalf of myself and Brian Auchin, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.