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


Transcript #113: Python Lands on the Windows 10 App Store

Return to episode page view on github
Recorded on Wednesday, Jan 16, 2019.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to

00:04 your earbuds. This is episode 113, recorded January 16th, 2019. I'm Michael Kennedy.

00:10 And I'm Brian Okken.

00:11 And this episode is brought to you by DigitalOcean. Check them out at pythonbytes.fm

00:16 slash DigitalOcean. Get $100 free credit for new users. Brian, how you been?

00:20 I am great.

00:21 Nice. Me too.

00:21 Cold though.

00:22 Yeah. I don't know what happened. It's like winter, mid-January. I guess it's supposed to

00:26 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

00:34 yet. I just bought snow tires for my car so I can drive up to the mountains and go skiing real easy.

00:38 So I'm ready. It can snow whenever. But yeah, if it's not going to snow, let it be a little warm.

00:43 So speaking of wintry type things, advent calendars, those are a type of things that folks use a lot

00:50 in December, right?

00:51 Yeah. And actually, this last December, I totally meant to do the advent of code thing,

00:56 but I didn't. And also one of the things I'm doing this upcoming year is I'm trying to,

01:01 I read a great article about practicing programming. I want to try to do, incorporate more practice

01:07 outside of just doing my own work at work, but practicing extra things. And there's challenges

01:14 and code things and little snippets and everything. But sometimes I just want like 20 minutes of reading

01:19 reading something. And this is great. So I ran across this. It's from Michael Fogelman. It's the

01:26 advent of code 2018 solutions. And it's pretty much he just talks through all the different,

01:33 he went through all of the advent of code for 2018, and then he solved them in Python. And a lot of people

01:39 have posted their solutions on GitHub. This is a nice write up that he has to describe how he solved

01:44 them. And there's some nice code comments. It's really put together well.

01:48 Yeah, I like it. You just sort of cruise through and see the problem, see the solution,

01:51 see what you think. I find looking at other people's solutions of fairly simple programs,

01:58 especially compared to your own. It's a pretty interesting experience. Like, oh yeah,

02:02 I totally solved this. And then you look like, oh wait, they did that in two lines and mine took 10.

02:07 Or why did they do it that way versus this? It's pretty cool.

02:10 Yeah. Looking over, reading code is one of the ways to get better. So it's a good way to practice

02:15 is reading other people's code.

02:16 Yeah. And it's not like read the Django source code or read the request source code. And it's like a huge

02:22 undertaking, right? These are 10, 2025 lines of code.

02:25 Yeah. Yep. Definitely. So I dropped this in because I think I'm going to start

02:30 trying to incorporate, sprinkle in some reading, reading of these in with my daily practice.

02:35 Yeah. I think that's a good idea. Do you know what the most popular platform that Python runs on

02:39 is, Brian?

02:40 Probably Macs. Mac laptops.

02:42 A lot of Mac, a lot of Mac laptops, a lot of stickers on them. That's what you'd believe if you

02:47 were at a conference like PyCon or something, everyone's running around with their Apple logos glowing or

02:52 sadly no longer glowing on the new Macs. But nonetheless, it feels like when you're in

02:57 those environments, it's mostly Mac and some Linux and obviously server side Linux. But really,

03:03 a lot of the surveys say most of the users, you know, by a pretty wide margin are actually on

03:10 Windows. So we're talking students, we're talking corporate environments, a lot of folks who don't

03:16 show up necessarily carrying those around at conferences, but that's where it is, right?

03:21 Yeah.

03:21 So the big news is that the PSF broadly and specifically Steve Dower, one of the core devs,

03:28 whose works at Microsoft, has released Python 3.7 as an official app on the Windows 10 store.

03:36 Nice.

03:37 So there's all sorts of stuff that is really awesome from that. So that means you can just

03:42 go to your Windows store and search for Python and say, yeah, I want that. You can actually already

03:48 do that for like Ubuntu subsystems and stuff. So you can do that for Linux distribution, surprisingly,

03:52 and run those as like subsystems in Windows, but not Python. And some of the stuff that's really cool is

03:58 it automatically takes care of a couple of problems that were incompatibilities between Windows and the

04:06 other operating systems. So for example, Python 3 is a command in the Windows 10 app store version,

04:13 but not the one you actually install separately. So now if you see instructions like type Python 3,

04:17 this, that, like that now works on Windows 2 also.

04:20 That's nice.

04:21 Yeah. So it's a little more similar. It automatically puts that stuff in the path. I believe the place

04:27 where you pip install stuff no longer requires admin access to do it because it's under your user

04:33 profile as part of the store stuff. So a whole bunch of good things.

04:35 Have you talked to anybody to find out when we're going to get to the point where

04:38 the default Python is going to be Python 3 anyway?

04:41 That would be sweet, wouldn't it? You know, all the stuff I've seen about it is like,

04:46 it would be great, but it also caused a lot of problems.

04:48 Yeah.

04:49 We saw that Red Hat Enterprise Linux is actually moving away from having a Python command at all.

04:55 So now it's either Python 3 or Python 2 and you have to be super explicit everywhere.

04:59 So I would love to see that, but I don't see it. On my systems, Python means Python 3 because I've

05:06 changed the path around. So that works that way, but not everywhere, you know?

05:10 Yeah. You recently talked about this and a lot of other things on Talk Python, right?

05:15 Yeah. I had Steve Dower come over onto Talk Python and talk about his retrospective of Python's

05:22 journey at Microsoft, which is actually really interesting. It sort of matches the open source

05:28 journey from a very closed source company to way more open source. And there's a lot of cool stuff

05:32 going on there. They have a ton of core developers working at Microsoft, actually. It's pretty neat.

05:37 Yeah. That was a really interesting conversation. I like that.

05:39 Yeah. Thanks. So there is one limitation on the Windows Store version of Python that maybe is

05:44 worth throwing out there while we're talking about it is they don't have full write access to shared

05:49 locations, like for example, the registry or SQL and backslash program files or stuff like that.

05:55 Right. So it's kind of only has access to your user profile stuff, you know, whatever you can do

06:00 without raising your permissions at UAC stuff. So that's a limitation that you may run into

06:06 because the Windows Store apps are more locked down than regular apps. But still, I think this is

06:11 super cool. You can go and just say, hey, you don't need to be an admin. You just go to your

06:14 Windows Store, you click this little button and you also have Python 3 as a command. It's quite nice.

06:19 Can you write stuff that's outside of your little environment? Not write stuff, but read it.

06:23 Yeah. I'm pretty sure you can. Like you could read the registry. I would think things like that,

06:27 whatever you would be able to do without that little, this program would like to use admin rights.

06:32 Yes, no dialogue pop-up. I suspect you'd be able to do. Yeah.

06:35 I think that's a good idea anyway. So it's going to be in the App Store.

06:38 Yeah, exactly. So, you know, I would actually love to see that on macOS, right? If Python 3 was an

06:44 option on macOS, because the auto-updating feature is pretty cool. Like you just wake up one day and

06:48 boom, you have the next version of Python. Of course, that could cause its own problems,

06:52 but it wouldn't be bad.

06:53 Python 5? What's that?

06:55 Oh my goodness. It's amazing and nothing works anymore. What happened?

06:59 No, that's pretty cool though. I'm happy to see it getting some serious attention over there.

07:04 Yeah. Definitely. All right. Well, when's next?

07:06 There's a project so new that it like came in in November this last year. It's a project called

07:11 Bocadio.

07:12 Yeah, that's how I would say it as well. Yeah. Bocadio.

07:15 Yeah.

07:16 Yeah, I think so.

07:16 Tagline is a modern Python web framework filled with asynchronous salsa. But the,

07:21 I'm not really going to talk about that. I'm going to talk about article that the,

07:24 the maintainer, it's a four month banca wrote an article called how I built a Python web framework

07:30 and became an open source maintainer. And it's this really fascinating article talking about pretty

07:37 much what he went through. He knew that there were a lot of other web frameworks already,

07:41 but he, he built this to try to learn the internals of how to build a web framework and then just did it in

07:46 the open. But there's some really great advice. One of the things he credits from somebody else

07:51 called Funky Bob is reinventing the wheel is an awesome way to learn. And sometimes what you learn

07:57 is just how much are your existing frameworks are doing for you. I thought that was cool.

08:02 That was very cool.

08:03 This thing went from like just inception to building it, to putting up docs and getting

08:09 extra maintainers in like the course of a month in November. And now it's, it's still going,

08:15 but there's like one of the discussions in the article is talking about how he tried to put as

08:20 much in the read me as possible right off the bat, like a change log and contributing guidelines and,

08:26 and how to work it and everything. But the read me got huge. So he, that migrated to

08:32 a GitHub pages, static site generator doc site. And then also one of the things is,

08:40 he had all of his to do items of what he wanted to work on next in a Trello doc in Trello,

08:45 but nobody else can see that. So he moved, Trello issues to GitHub issues.

08:50 And this process of trying to make, do a new project in a way that is open and encouraging other

08:57 people to help out. And then at the end of the article, it goes through, I'm not going to go through

09:01 all of these, but there's a whole bunch of tips on what to do with the project to make it encourage

09:07 other people to get involved. And this is like a goldmine of information for people wanting to start

09:12 an open source project.

09:13 Yeah. If you're thinking about an open source project or how to make it grow, there's, you're

09:18 right. There is an incredible amount of tips. I mean, there's probably 45 specific things like

09:23 this helps, this helps, this helps, right? So that's, that's really awesome.

09:27 Yeah. If all this information at the bottom, he could have written, written a book on this.

09:32 and maybe he will, but yeah, maybe he will.

09:33 But thanks, Floremund for putting this together.

09:36 Yeah, it looks great. And the framework looks pretty nice as well. I like it. I feel like a lot

09:41 of these web frameworks are like slight derivatives of the Flask API. They seem to all be centering

09:48 around Flask for some reason, but you know, Flask is pretty good. So that's cool.

09:52 Yeah.

09:52 Speaking of cool, I heard Kubernetes is cool. Kelsey Hightower told us it was,

09:56 and definitely showed us a cool demo at a PyCon.

09:59 Yeah. I believe anything Kelsey says.

10:00 Yeah, for sure. So Kubernetes is a way to basically orchestrate containers, right? Often you don't want

10:07 to run one container. You want to run multiple ones, one with a database, a couple of web front ends,

10:12 things like that. And it's really nice way to like do zero downtime deployment on top of that and so on.

10:18 So DigitalOcean, who's sponsoring the show, of course, has just officially publicly released,

10:25 no longer preview status, their DigitalOcean Kubernetes service. So it's like a managed service

10:31 and you can basically sign up for it and configure a Kubernetes cluster in a couple of seconds and

10:39 provision it and log in within a couple of minutes. So it's super easy to scale. You take inbound traffic

10:45 and just access your data over block storage, pass it through your load balancers. It's all great.

10:51 So they also say they saw a 2.4 times, not percent, times better price to performance compared to other

10:59 providers. So I can definitely believe that DigitalOcean is awesome. So anyway, if you're thinking about this,

11:05 check them out at pythonbytes.fm/DigitalOcean, get $100 free credit for new users and try your hand at some

11:12 Kubernetes clusters. Nice. Yeah, indeed. You could even probably, you know, serve up Bocadio on Kubernetes.

11:19 That'd be fun. Yeah. Cool. Well, one thing that we talked about recently, and so this is a little bit of a

11:26 follow-up is the maintainability score. Do you remember what we were talking about with the

11:30 maintainability score? It was like a sub idea of something that we were covering recently.

11:34 I totally remember, but I don't remember the main topic.

11:37 I don't. It's always so many things we cover every week. But yeah, it's one of the projects and it was

11:41 like, hey, this has a maintainability score of A. And we're like, wait, where did you get that score?

11:45 So a friend of the show, Anthony Shaw sent over, you know, he's done this project called Wiley.

11:51 Did you guys talk about it on your show?

11:52 We talked about it briefly, yeah.

11:54 Yeah. So Wiley is a Python app for tracking and reporting on timing and complexity and tests and

12:02 things like that. So what you can do is you can point this at your project and tell it to analyze it

12:07 and then generate a bunch of reports. And it has two types of reports that are relevant to this

12:13 maintainability index. It has just a number, like a percentage, and I think higher is better there.

12:17 And also it has a rank from like A to F, like a grade score on it. So you can run this against

12:24 your code and ask it. And then you can even graph that kind of stuff over time. So it's getting,

12:29 on the reports, it'll say, ah, it's lost some maintainability or it's gained some maintainability,

12:34 which I thought was pretty cool.

12:35 Yeah, that is cool.

12:36 Yeah.

12:37 So check out Anthony's project. I'll link to it, of course, in the show notes. And if

12:42 you can see how well or not well Wiley thinks your app is doing. Even has a GitHub pre-commit hook,

12:49 as all the cool things do these days.

12:51 Yeah. That's a fairly new project too. Wiley's only been around for a couple,

12:55 two, three months or something.

12:56 Yeah, absolutely. It's pretty new. Would you say it's awesome?

12:59 I would say it's awesome. I think so. Yeah.

13:02 What else is awesome?

13:03 I kind of like the awesome lists. So awesome lists, if you're not familiar with them,

13:07 are, they're usually on GitHub, but they're basically, the readme is filled with links to

13:12 a whole bunch of other, other projects of a particular type. There's two awesome lists that

13:17 I came across recently. One of them is awesome Python security resources. And the other one is

13:23 awesome Flake 8 extensions. So as far as security resources, it covers tools and education resources.

13:32 And then a couple of companies also.

13:34 The very first one that it has listed here is secure.py, which we talked about just I think last week or just recently.

13:39 Yeah. And we've also, I think we've talked about Bandit also for static analysis.

13:43 Yeah.

13:44 Some of these we've talked about. And, and then I also, I really liked that it also included some education resources.

13:49 If you want to learn more about security.

13:52 For sure.

13:52 For your software. So this is a nice place to go for security stuff.

13:56 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.

14:09 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.

14:15 I don't know the elevator pitch. It's not PEP 8 anymore. It's like PyCode style or something like that.

14:21 Yeah. It's a format, basically the formatting conventions of the language, right?

14:26 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.

14:33 What it does cyclical, some complexity algorithm and gosh, you're putting me on the spot here, man.

14:40 No, no, that's close enough though. But so basically it analyzes the quality of your code, right? But it only does so much.

14:45 But it's definitely a static analysis. It's just looking at, looking at it just without running it.

14:51 So you found a couple of plugins for it?

14:53 Yeah. The extensions, there's a whole bunch of them. There's some security ones that actually overlap.

14:59 The other, the security resources in the previous list, if you can run them from Flake 8.

15:06 So like the static analysis that's available for security, like Bandit, I think there's a Flake 8 Bandit.

15:11 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.

15:19 It doesn't actually run your pytest. What it does is it, it checks to make sure that you've got pytest style assertions.

15:25 So one of the benefits of pytest is just regular assertions and not like the unit test stuff.

15:31 If you've converted from unit test to pytest, you might still have some of those other assertions laying around in this one.

15:38 I'll try to get rid of those.

15:39 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.

15:50 Validates this restructured text of your documentation. That's sweet.

15:55 Oh, that's nice. Yeah.

15:56 Yeah.

15:56 So there's just so many in here.

15:58 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.

16:05 So the point of mock is to fake out existing functionality so that you do something different.

16:12 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.

16:21 Your code won't run.

16:23 This plugin will check to make sure that you're mocking real existing methods and not made up methods.

16:28 Yeah. Cool. Well, these are great. These are awesome finds, right?

16:31 Yeah.

16:31 Another thing that's awesome is logging. So remember a couple of weeks ago, we talked about Log Guru?

16:38 Yeah.

16:38 Log Guru? Log Guru? We don't know.

16:40 Log Guru.

16:40 We'll just try all the variations until one of them hits, I'm guessing.

16:44 And of course, just kind of-

16:46 I think it rhymes with kangaroo.

16:47 It does. And so just like when we talked about GUI frameworks, we're like, oh,

16:52 here's like a couple of them. And just people are like, oh, and did you know? Did you know?

16:55 So here's another really cool logging framework that Robert Young sent over to us to say, oh,

17:00 you talked about Log Guru. You should definitely check this out.

17:03 So this is called Fast Logging.

17:05 So Fast Logging is a replacement for the standard logging module, and it's mostly compatible,

17:11 which is pretty cool. But would you guess from the name that it's faster?

17:15 I should hope so.

17:16 So basically the point is logging can be kind of slow, it turns out, in the standard logging module.

17:22 But this one is faster. And not just like 20% faster, it's like five times faster for a regular

17:28 file. And if you're doing rotating log files, it's actually about 13 times faster.

17:32 So if you're doing a lot of logging and it's turning, basically the logging is slowing down

17:36 your app, think about fast logging.

17:38 Yeah. Nice.

17:39 Yeah. And it has a bunch of cool features. So like if you install Colorama, which is a great

17:45 color way to do output on the console, it'll actually do colored logging when it's logging

17:51 to print, you know, standard out. You can set the maximum file size and rotating a lot of

17:57 options on the rotating stuff. It'll also like Log Guru compress the older file, older log

18:03 files, which can be 10x or more savings. Like those log files compress really, really well.

18:08 You can do like only log every so often based on domains, different files, like all sorts of

18:13 stuff. You get callbacks. One thing that's kind of cool is it'll do logging on background threads

18:19 per file, which is pretty cool if you configure it. So if you're like, I want to log this stuff,

18:24 but I know that might slow down my app and I don't want any slowdown. So this will basically

18:29 push it off to a background thread, which will eventually pick it up and write it. So you can

18:34 get, keep stuff flowing right along, maybe in a web request or something like that. It's pretty cool.

18:39 Yeah. Yeah. Very nice.

18:40 Yeah. So thanks Robert for sending that in. That's a good one.

18:42 Brian, that's it for our official items. Got anything else?

18:46 I actually don't.

18:46 Nope. All right. Right on.

18:48 How about you?

18:49 Well, I have two things that I'd like to just throw out there really quick. First of all,

18:53 I'm doing a live webcast, but also be recorded over on January 24th at 11 AM Pacific time,

19:00 basically working and showing async and await in Python and building a little app that uses that.

19:07 So if you got a free hour and you want to drop in, check that out, put the links in the show notes

19:11 there. And we already talked about Anthony Shaw and his Wiley, but he also sent over a heads up,

19:19 which I also got from GitHub to watch your YAML. YAML apparently had some pretty decent security

19:27 vulnerability. Like, I don't know how many people know, but you can actually just straight up execute

19:31 arbitrary Python code in a YAML file. That's bad, right? So like, yeah. So, Hey, upload your

19:38 configuration file and we'll just run it for you. And like the configuration file is like,

19:42 username is this password is that database format is this bang Python format, the system or do other

19:50 bad things. Right? Like it was really crazy that the YAML format just lets you embed code into what

19:56 is otherwise supposed to be a static file. All right. So the warning is that you're supposed to use,

20:01 what's it called? Safe underscore load instead of load, but they've fixed some stuff to make that

20:07 basically make that more obvious. And with a new version of PyYAML. So if you're using PyYAML,

20:11 GitHub will give you a warning about this. Anyway, it seems like it could actually have a lot of

20:17 consequences if you don't update that. So check that out. Yeah. But also if you're using PyYAML,

20:21 updating to the newest version should fix that, right? Yes, you should. But what's weird is we talked

20:27 about zero for the way you fix the PyYAML problem is you take a, an official, like, I'm just messing with it,

20:33 like 1.3 release and you upgrade it to a beta release. So it's like, so you have to install

20:39 the beta version to not have the security problem, which I don't know, take that for what it is.

20:44 Yeah. Okay. Come on, PyYAML people. That's right. All right. Do you have a joke for us this week?

20:49 I don't. All right. I have a joke. This is an oldie, but a goodie. It's about Python,

20:55 which is pretty sweet. So if you're out there and you type Python on your terminal command prompt,

21:00 and then you just import anti-gravity, like the command, right? Import anti-gravity.

21:05 It turns out, have you done this, Brian, before? Yeah, but it's good to bring it up because some

21:10 people don't know about it. Yeah, exactly. This is one of the better things built into the Python

21:14 repo, honestly. And so what it does is it actually opens up an XKCD comic, which is a great joke

21:21 about Python's packages and libraries. So there's a picture, there's a stick figure flying up in the air

21:27 and the stick figure on the ground, obviously amazement on his blank face, stick face says,

21:34 how are you flying? Python. I just learned it last night. Everything's so simple. Hello world is

21:40 just print. Hello world. The guy on the ground says, I don't know. Dynamic typing, white space.

21:45 Guy in the air says, come on, join us. Programming is fun again. It's a whole new world up here,

21:49 but how are you flying? I just typed import anti-gravity. That's it. I also sampled everything

21:55 in the medicine cabinet for comparison, but I think it's the Python. It's a good, it's a little bit

22:01 of goody, right? Yeah. Yeah. And while you're playing on the command line, it's not a joke,

22:05 but import this. It's another hidden Easter egg, not very hidden, but that it'll show you the Zen of

22:12 Python. Yep. That's awesome. I'm going to save another import joke that you can do on the terminal

22:16 or in the REPL for next time or time after. Okay. But yeah, it's, I really love it that

22:22 these kinds of jokes and humorous things are built in there. It's not like Python has been sterilized of

22:27 all humanity. Yeah. And anti-gravity connects Python with XKCD, which is kind of neat. And one of the

22:34 things I like, I can't remember where to get these, but one of the things I like about XKCD is they often

22:40 talk about things that you might not know about. There's another place that I can't remember where

22:45 it discusses like why it's funny. So you can read about things you don't know about. Yeah, absolutely.

22:51 Absolutely. Well, thanks for recording this week. You bet. It's always fun and I always learn something.

22:56 So thanks a bunch. Bye. Thank you for listening to Python Bytes. Follow the show on Twitter via

23:00 at Python Bytes. That's Python Bytes as in B-Y-T-E-S. And get the full show notes at pythonbytes.fm.

23:08 If you have a news item you want featured, just visit pythonbytes.fm and send it our way. We're

23:12 always on the lookout for sharing something cool. On behalf of myself and Brian Okken,

23:17 this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page