Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
your earbuds. This is episode 113, recorded January 16th, 2019. I'm Michael Kennedy.
And I'm Brian Okken.
And this episode is brought to you by DigitalOcean. Check them out at pythonbytes.fm
slash DigitalOcean. Get $100 free credit for new users. Brian, how you been?
I am great.
Nice. Me too.
Cold though.
Yeah. I don't know what happened. It's like winter, mid-January. I guess it's supposed to
be cold. But yeah, it's cold. Maybe. My daughter said this morning,
like, when are we going to get snow? And I said, well, I hope never because I don't have snow tires
yet. I just bought snow tires for my car so I can drive up to the mountains and go skiing real easy.
So I'm ready. It can snow whenever. But yeah, if it's not going to snow, let it be a little warm.
So speaking of wintry type things, advent calendars, those are a type of things that folks use a lot
in December, right?
Yeah. And actually, this last December, I totally meant to do the advent of code thing,
but I didn't. And also one of the things I'm doing this upcoming year is I'm trying to,
I read a great article about practicing programming. I want to try to do, incorporate more practice
outside of just doing my own work at work, but practicing extra things. And there's challenges
and code things and little snippets and everything. But sometimes I just want like 20 minutes of reading
reading something. And this is great. So I ran across this. It's from Michael Fogelman. It's the
advent of code 2018 solutions. And it's pretty much he just talks through all the different,
he went through all of the advent of code for 2018, and then he solved them in Python. And a lot of people
have posted their solutions on GitHub. This is a nice write up that he has to describe how he solved
them. And there's some nice code comments. It's really put together well.
Yeah, I like it. You just sort of cruise through and see the problem, see the solution,
see what you think. I find looking at other people's solutions of fairly simple programs,
especially compared to your own. It's a pretty interesting experience. Like, oh yeah,
I totally solved this. And then you look like, oh wait, they did that in two lines and mine took 10.
Or why did they do it that way versus this? It's pretty cool.
Yeah. Looking over, reading code is one of the ways to get better. So it's a good way to practice
is reading other people's code.
Yeah. And it's not like read the Django source code or read the request source code. And it's like a huge
undertaking, right? These are 10, 2025 lines of code.
Yeah. Yep. Definitely. So I dropped this in because I think I'm going to start
trying to incorporate, sprinkle in some reading, reading of these in with my daily practice.
Yeah. I think that's a good idea. Do you know what the most popular platform that Python runs on
is, Brian?
Probably Macs. Mac laptops.
A lot of Mac, a lot of Mac laptops, a lot of stickers on them. That's what you'd believe if you
were at a conference like PyCon or something, everyone's running around with their Apple logos glowing or
sadly no longer glowing on the new Macs. But nonetheless, it feels like when you're in
those environments, it's mostly Mac and some Linux and obviously server side Linux. But really,
a lot of the surveys say most of the users, you know, by a pretty wide margin are actually on
Windows. So we're talking students, we're talking corporate environments, a lot of folks who don't
show up necessarily carrying those around at conferences, but that's where it is, right?
Yeah.
So the big news is that the PSF broadly and specifically Steve Dower, one of the core devs,
whose works at Microsoft, has released Python 3.7 as an official app on the Windows 10 store.
Nice.
So there's all sorts of stuff that is really awesome from that. So that means you can just
go to your Windows store and search for Python and say, yeah, I want that. You can actually already
do that for like Ubuntu subsystems and stuff. So you can do that for Linux distribution, surprisingly,
and run those as like subsystems in Windows, but not Python. And some of the stuff that's really cool is
it automatically takes care of a couple of problems that were incompatibilities between Windows and the
other operating systems. So for example, Python 3 is a command in the Windows 10 app store version,
but not the one you actually install separately. So now if you see instructions like type Python 3,
this, that, like that now works on Windows 2 also.
That's nice.
Yeah. So it's a little more similar. It automatically puts that stuff in the path. I believe the place
where you pip install stuff no longer requires admin access to do it because it's under your user
profile as part of the store stuff. So a whole bunch of good things.
Have you talked to anybody to find out when we're going to get to the point where
the default Python is going to be Python 3 anyway?
That would be sweet, wouldn't it? You know, all the stuff I've seen about it is like,
it would be great, but it also caused a lot of problems.
Yeah.
We saw that Red Hat Enterprise Linux is actually moving away from having a Python command at all.
So now it's either Python 3 or Python 2 and you have to be super explicit everywhere.
So I would love to see that, but I don't see it. On my systems, Python means Python 3 because I've
changed the path around. So that works that way, but not everywhere, you know?
Yeah. You recently talked about this and a lot of other things on Talk Python, right?
Yeah. I had Steve Dower come over onto Talk Python and talk about his retrospective of Python's
journey at Microsoft, which is actually really interesting. It sort of matches the open source
journey from a very closed source company to way more open source. And there's a lot of cool stuff
going on there. They have a ton of core developers working at Microsoft, actually. It's pretty neat.
Yeah. That was a really interesting conversation. I like that.
Yeah. Thanks. So there is one limitation on the Windows Store version of Python that maybe is
worth throwing out there while we're talking about it is they don't have full write access to shared
locations, like for example, the registry or SQL and backslash program files or stuff like that.
Right. So it's kind of only has access to your user profile stuff, you know, whatever you can do
without raising your permissions at UAC stuff. So that's a limitation that you may run into
because the Windows Store apps are more locked down than regular apps. But still, I think this is
super cool. You can go and just say, hey, you don't need to be an admin. You just go to your
Windows Store, you click this little button and you also have Python 3 as a command. It's quite nice.
Can you write stuff that's outside of your little environment? Not write stuff, but read it.
Yeah. I'm pretty sure you can. Like you could read the registry. I would think things like that,
whatever you would be able to do without that little, this program would like to use admin rights.
Yes, no dialogue pop-up. I suspect you'd be able to do. Yeah.
I think that's a good idea anyway. So it's going to be in the App Store.
Yeah, exactly. So, you know, I would actually love to see that on macOS, right? If Python 3 was an
option on macOS, because the auto-updating feature is pretty cool. Like you just wake up one day and
boom, you have the next version of Python. Of course, that could cause its own problems,
but it wouldn't be bad.
Python 5? What's that?
Oh my goodness. It's amazing and nothing works anymore. What happened?
No, that's pretty cool though. I'm happy to see it getting some serious attention over there.
Yeah. Definitely. All right. Well, when's next?
There's a project so new that it like came in in November this last year. It's a project called
Bocadio.
Yeah, that's how I would say it as well. Yeah. Bocadio.
Yeah.
Yeah, I think so.
Tagline is a modern Python web framework filled with asynchronous salsa. But the,
I'm not really going to talk about that. I'm going to talk about article that the,
the maintainer, it's a four month banca wrote an article called how I built a Python web framework
and became an open source maintainer. And it's this really fascinating article talking about pretty
much what he went through. He knew that there were a lot of other web frameworks already,
but he, he built this to try to learn the internals of how to build a web framework and then just did it in
the open. But there's some really great advice. One of the things he credits from somebody else
called Funky Bob is reinventing the wheel is an awesome way to learn. And sometimes what you learn
is just how much are your existing frameworks are doing for you. I thought that was cool.
That was very cool.
This thing went from like just inception to building it, to putting up docs and getting
extra maintainers in like the course of a month in November. And now it's, it's still going,
but there's like one of the discussions in the article is talking about how he tried to put as
much in the read me as possible right off the bat, like a change log and contributing guidelines and,
and how to work it and everything. But the read me got huge. So he, that migrated to
a GitHub pages, static site generator doc site. And then also one of the things is,
he had all of his to do items of what he wanted to work on next in a Trello doc in Trello,
but nobody else can see that. So he moved, Trello issues to GitHub issues.
And this process of trying to make, do a new project in a way that is open and encouraging other
people to help out. And then at the end of the article, it goes through, I'm not going to go through
all of these, but there's a whole bunch of tips on what to do with the project to make it encourage
other people to get involved. And this is like a goldmine of information for people wanting to start
an open source project.
Yeah. If you're thinking about an open source project or how to make it grow, there's, you're
right. There is an incredible amount of tips. I mean, there's probably 45 specific things like
this helps, this helps, this helps, right? So that's, that's really awesome.
Yeah. If all this information at the bottom, he could have written, written a book on this.
and maybe he will, but yeah, maybe he will.
But thanks, Floremund for putting this together.
Yeah, it looks great. And the framework looks pretty nice as well. I like it. I feel like a lot
of these web frameworks are like slight derivatives of the Flask API. They seem to all be centering
around Flask for some reason, but you know, Flask is pretty good. So that's cool.
Yeah.
Speaking of cool, I heard Kubernetes is cool. Kelsey Hightower told us it was,
and definitely showed us a cool demo at a PyCon.
Yeah. I believe anything Kelsey says.
Yeah, for sure. So Kubernetes is a way to basically orchestrate containers, right? Often you don't want
to run one container. You want to run multiple ones, one with a database, a couple of web front ends,
things like that. And it's really nice way to like do zero downtime deployment on top of that and so on.
So DigitalOcean, who's sponsoring the show, of course, has just officially publicly released,
no longer preview status, their DigitalOcean Kubernetes service. So it's like a managed service
and you can basically sign up for it and configure a Kubernetes cluster in a couple of seconds and
provision it and log in within a couple of minutes. So it's super easy to scale. You take inbound traffic
and just access your data over block storage, pass it through your load balancers. It's all great.
So they also say they saw a 2.4 times, not percent, times better price to performance compared to other
providers. So I can definitely believe that DigitalOcean is awesome. So anyway, if you're thinking about this,
check them out at pythonbytes.fm/DigitalOcean, get $100 free credit for new users and try your hand at some
Kubernetes clusters. Nice. Yeah, indeed. You could even probably, you know, serve up Bocadio on Kubernetes.
That'd be fun. Yeah. Cool. Well, one thing that we talked about recently, and so this is a little bit of a
follow-up is the maintainability score. Do you remember what we were talking about with the
maintainability score? It was like a sub idea of something that we were covering recently.
I totally remember, but I don't remember the main topic.
I don't. It's always so many things we cover every week. But yeah, it's one of the projects and it was
like, hey, this has a maintainability score of A. And we're like, wait, where did you get that score?
So a friend of the show, Anthony Shaw sent over, you know, he's done this project called Wiley.
Did you guys talk about it on your show?
We talked about it briefly, yeah.
Yeah. So Wiley is a Python app for tracking and reporting on timing and complexity and tests and
things like that. So what you can do is you can point this at your project and tell it to analyze it
and then generate a bunch of reports. And it has two types of reports that are relevant to this
maintainability index. It has just a number, like a percentage, and I think higher is better there.
And also it has a rank from like A to F, like a grade score on it. So you can run this against
your code and ask it. And then you can even graph that kind of stuff over time. So it's getting,
on the reports, it'll say, ah, it's lost some maintainability or it's gained some maintainability,
which I thought was pretty cool.
Yeah, that is cool.
Yeah.
So check out Anthony's project. I'll link to it, of course, in the show notes. And if
you can see how well or not well Wiley thinks your app is doing. Even has a GitHub pre-commit hook,
as all the cool things do these days.
Yeah. That's a fairly new project too. Wiley's only been around for a couple,
two, three months or something.
Yeah, absolutely. It's pretty new. Would you say it's awesome?
I would say it's awesome. I think so. Yeah.
What else is awesome?
I kind of like the awesome lists. So awesome lists, if you're not familiar with them,
are, they're usually on GitHub, but they're basically, the readme is filled with links to
a whole bunch of other, other projects of a particular type. There's two awesome lists that
I came across recently. One of them is awesome Python security resources. And the other one is
awesome Flake 8 extensions. So as far as security resources, it covers tools and education resources.
And then a couple of companies also.
The very first one that it has listed here is secure.py, which we talked about just I think last week or just recently.
Yeah. And we've also, I think we've talked about Bandit also for static analysis.
Yeah.
Some of these we've talked about. And, and then I also, I really liked that it also included some education resources.
If you want to learn more about security.
For sure.
For your software. So this is a nice place to go for security stuff.
And then I like Flake 8 anyway, as just as a tool by itself for static code analysis. But I, I like that it has a plugin system with it. And so there's lots of different extensions to Flake 8.
So Brian, for the couple of folks out there who don't know what Flake is, Flake 8 is, give them a quick, the elevator pitch.
I don't know the elevator pitch. It's not PEP 8 anymore. It's like PyCode style or something like that.
Yeah. It's a format, basically the formatting conventions of the language, right?
Yeah. Flake 8 itself runs the checks for those, but it, and I think the 8 is because it checks a whole bunch of other things.
What it does cyclical, some complexity algorithm and gosh, you're putting me on the spot here, man.
No, no, that's close enough though. But so basically it analyzes the quality of your code, right? But it only does so much.
But it's definitely a static analysis. It's just looking at, looking at it just without running it.
So you found a couple of plugins for it?
Yeah. The extensions, there's a whole bunch of them. There's some security ones that actually overlap.
The other, the security resources in the previous list, if you can run them from Flake 8.
So like the static analysis that's available for security, like Bandit, I think there's a Flake 8 Bandit.
There's also a couple of my favorites are, this is interesting. There's a Flake 8 pytest extension that I want to try this.
It doesn't actually run your pytest. What it does is it, it checks to make sure that you've got pytest style assertions.
So one of the benefits of pytest is just regular assertions and not like the unit test stuff.
If you've converted from unit test to pytest, you might still have some of those other assertions laying around in this one.
I'll try to get rid of those.
Yeah. One that pops out to me is like Flake 8 dash docstrings, which actually checks the docstring code for you, which is pretty awesome.
Validates this restructured text of your documentation. That's sweet.
Oh, that's nice. Yeah.
Yeah.
So there's just so many in here.
Yeah. And there was, I didn't write this one down. There was one that like checks for, it checks to make sure that you're not mocking things that didn't exist.
So the point of mock is to fake out existing functionality so that you do something different.
One of the things that you can muck up with is you can be mocking the wrong function name and it'll work just fine in your tests.
Your code won't run.
This plugin will check to make sure that you're mocking real existing methods and not made up methods.
Yeah. Cool. Well, these are great. These are awesome finds, right?
Yeah.
Another thing that's awesome is logging. So remember a couple of weeks ago, we talked about Log Guru?
Yeah.
Log Guru? Log Guru? We don't know.
Log Guru.
We'll just try all the variations until one of them hits, I'm guessing.
And of course, just kind of-
I think it rhymes with kangaroo.
It does. And so just like when we talked about GUI frameworks, we're like, oh,
here's like a couple of them. And just people are like, oh, and did you know? Did you know?
So here's another really cool logging framework that Robert Young sent over to us to say, oh,
you talked about Log Guru. You should definitely check this out.
So this is called Fast Logging.
So Fast Logging is a replacement for the standard logging module, and it's mostly compatible,
which is pretty cool. But would you guess from the name that it's faster?
I should hope so.
So basically the point is logging can be kind of slow, it turns out, in the standard logging module.
But this one is faster. And not just like 20% faster, it's like five times faster for a regular
file. And if you're doing rotating log files, it's actually about 13 times faster.
So if you're doing a lot of logging and it's turning, basically the logging is slowing down
your app, think about fast logging.
Yeah. Nice.
Yeah. And it has a bunch of cool features. So like if you install Colorama, which is a great
color way to do output on the console, it'll actually do colored logging when it's logging
to print, you know, standard out. You can set the maximum file size and rotating a lot of
options on the rotating stuff. It'll also like Log Guru compress the older file, older log
files, which can be 10x or more savings. Like those log files compress really, really well.
You can do like only log every so often based on domains, different files, like all sorts of
stuff. You get callbacks. One thing that's kind of cool is it'll do logging on background threads
per file, which is pretty cool if you configure it. So if you're like, I want to log this stuff,
but I know that might slow down my app and I don't want any slowdown. So this will basically
push it off to a background thread, which will eventually pick it up and write it. So you can
get, keep stuff flowing right along, maybe in a web request or something like that. It's pretty cool.
Yeah. Yeah. Very nice.
Yeah. So thanks Robert for sending that in. That's a good one.
Brian, that's it for our official items. Got anything else?
I actually don't.
Nope. All right. Right on.
How about you?
Well, I have two things that I'd like to just throw out there really quick. First of all,
I'm doing a live webcast, but also be recorded over on January 24th at 11 AM Pacific time,
basically working and showing async and await in Python and building a little app that uses that.
So if you got a free hour and you want to drop in, check that out, put the links in the show notes
there. And we already talked about Anthony Shaw and his Wiley, but he also sent over a heads up,
which I also got from GitHub to watch your YAML. YAML apparently had some pretty decent security
vulnerability. Like, I don't know how many people know, but you can actually just straight up execute
arbitrary Python code in a YAML file. That's bad, right? So like, yeah. So, Hey, upload your
configuration file and we'll just run it for you. And like the configuration file is like,
username is this password is that database format is this bang Python format, the system or do other
bad things. Right? Like it was really crazy that the YAML format just lets you embed code into what
is otherwise supposed to be a static file. All right. So the warning is that you're supposed to use,
what's it called? Safe underscore load instead of load, but they've fixed some stuff to make that
basically make that more obvious. And with a new version of PyYAML. So if you're using PyYAML,
GitHub will give you a warning about this. Anyway, it seems like it could actually have a lot of
consequences if you don't update that. So check that out. Yeah. But also if you're using PyYAML,
updating to the newest version should fix that, right? Yes, you should. But what's weird is we talked
about zero for the way you fix the PyYAML problem is you take a, an official, like, I'm just messing with it,
like 1.3 release and you upgrade it to a beta release. So it's like, so you have to install
the beta version to not have the security problem, which I don't know, take that for what it is.
Yeah. Okay. Come on, PyYAML people. That's right. All right. Do you have a joke for us this week?
I don't. All right. I have a joke. This is an oldie, but a goodie. It's about Python,
which is pretty sweet. So if you're out there and you type Python on your terminal command prompt,
and then you just import anti-gravity, like the command, right? Import anti-gravity.
It turns out, have you done this, Brian, before? Yeah, but it's good to bring it up because some
people don't know about it. Yeah, exactly. This is one of the better things built into the Python
repo, honestly. And so what it does is it actually opens up an XKCD comic, which is a great joke
about Python's packages and libraries. So there's a picture, there's a stick figure flying up in the air
and the stick figure on the ground, obviously amazement on his blank face, stick face says,
how are you flying? Python. I just learned it last night. Everything's so simple. Hello world is
just print. Hello world. The guy on the ground says, I don't know. Dynamic typing, white space.
Guy in the air says, come on, join us. Programming is fun again. It's a whole new world up here,
but how are you flying? I just typed import anti-gravity. That's it. I also sampled everything
in the medicine cabinet for comparison, but I think it's the Python. It's a good, it's a little bit
of goody, right? Yeah. Yeah. And while you're playing on the command line, it's not a joke,
but import this. It's another hidden Easter egg, not very hidden, but that it'll show you the Zen of
Python. Yep. That's awesome. I'm going to save another import joke that you can do on the terminal
or in the REPL for next time or time after. Okay. But yeah, it's, I really love it that
these kinds of jokes and humorous things are built in there. It's not like Python has been sterilized of
all humanity. Yeah. And anti-gravity connects Python with XKCD, which is kind of neat. And one of the
things I like, I can't remember where to get these, but one of the things I like about XKCD is they often
talk about things that you might not know about. There's another place that I can't remember where
it discusses like why it's funny. So you can read about things you don't know about. Yeah, absolutely.
Absolutely. Well, thanks for recording this week. You bet. It's always fun and I always learn something.
So thanks a bunch. 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 Okken,
this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.