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 your earbuds.

00:05 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.

00:14 Check them out at pythonbytes.fm/digitalocean.

00:17 Get $100 free credit for new users.

00:19 Brian, how you been?

00:20 I am great.

00:21 Nice. Me too.

00:21 Cold though.

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

00:25 I guess it's supposed to be cold.

00:27 But yeah, it's cold.

00:28 Maybe. My daughter said this morning, like, when are we going to get snow?

00:31 And I said, well, I hope never because I don't have snow tires yet.

00:34 So 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 in December, right?

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

00:57 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 I just want like 20 minutes of reading something and this is great. So I ran across this It's from Michael Fogelman. It's the Advent of Code 2018 solutions.

01:29 And it's pretty much he just talks through all the different...

01:32 He went through all of the Advent of Code for 2018 and then he solved them in Python.

01:37 And a lot of people have posted their solutions on GitHub.

01:40 This is a nice write-up that he has to describe how he solved them.

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

01:47 Yeah, I like it. You just sort of cruise through and see the problem, see the solution, see what you think.

01:52 I find looking at other people's solutions of fairly simple programs, especially compared to your own, it's a pretty interesting experience.

02:01 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.

02:10 Yeah, looking over, reading code is one of the ways to get better.

02:13 So it's a good way to practice 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 undertaking, right?

02:23 These are 10, 20, 25 lines of code.

02:25 Yeah, yep, definitely.

02:27 So I dropped this in because I think I'm going to start trying to incorporate, sprinkle in some reading, reading of these into my daily practice.

02:35 Yeah, I think that's a good idea.

02:36 Do you know what the most popular platform that Python runs on 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.

02:46 That's what you'd believe if you were at a conference like PyCon or something.

02:49 Everyone's running around with their Apple logos glowing or sadly no longer glowing on the new Macs.

02:54 But nonetheless, it feels like when you're in those environments, it's mostly Mac and some Linux and obviously server-side Linux.

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

03:11 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?

03:21 Yeah.

03:21 So the big news is that the PSF, broadly, and specifically Steve Dower, one of the core devs, who 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.

03:40 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 Ubuntu subsystems and stuff.

03:50 You can do that for Linux distribution, surprisingly, and run those as subsystems in Windows, but not Python.

03:57 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.

04:07 So, for example, Python 3 is a command in the Windows 10 App Store version, but not the one you actually install separately.

04:15 So now if you see instructions like type Python 3 this that that now works on Windows too also.

04:21 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, it's 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.

04:42 That would be sweet, wouldn't it?

04:43 You know, all the stuff I've seen about it is like, it would be great, but it would also cause a lot of problems.

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.

05:00 So I would love to see that, but I don't see it.

05:03 On my systems, Python means Python 3, because I've changed the path around, so that works that way.

05:09 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 journey at Microsoft, which is actually really interesting.

05:25 It sort of matches the open source journey from a very closed source company to way more open source.

05:31 And there's a lot of cool stuff going on there.

05:33 They have a ton of core developers working at Microsoft, actually.

05:36 It's pretty neat.

05:37 - Yeah, that was a really interesting conversation.

05:38 I liked that. - Yeah, thanks.

05:40 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 right access to shared locations like for example, the registry or SQL and backslash program files or stuff like that.

05:56 Right.

05:57 So it's kind of only has access to your user profile stuff, you know, whatever you can do without raising your permissions that you see stuff.

06:04 So that's a limitation that you may run into because the Windows Store apps are more locked down than regular apps.

06:10 But still, I think this is super cool.

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

06:14 You just go to your Windows Store.

06:15 You click this little button.

06:16 And you also have Python 3 as a command.

06:18 It's quite nice.

06:19 Can you write stuff that's outside of your little environment?

06:22 Not write stuff, but read it.

06:23 Yeah, I'm pretty sure you can.

06:24 Like, you could read the registry, I would think.

06:26 Things like that.

06:27 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.

06:35 I think that's a good idea anyway.

06:37 So it's going to be in the App Store.

06:38 Yeah, exactly.

06:39 So I would actually love to see that on macOS, if Python 3 was an option on macOS, because the auto-updating feature is pretty cool.

06:47 Like you just wake up one day, and boom, you have the next version of Python.

06:50 Of course, that could cause its own problems, but it wouldn't be bad.

06:54 Python 5?

06:55 What's that?

06:56 Oh my goodness.

06:57 It's amazing.

06:58 Nothing works anymore.

06:59 What happened?

07:00 No, that's pretty cool, though.

07:01 I'm happy to see it getting some serious attention over there.

07:04 Yeah.

07:04 Definitely.

07:05 All right.

07:05 Well, what's next?

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

07:10 It's a project called a Bocadillo.

07:13 Yeah.

07:13 That's how I would say it as well.

07:14 Yeah.

07:14 A Bocadillo.

07:15 Yeah.

07:16 Yeah.

07:16 I think so.

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

07:20 But the, I'm not really going to talk about that.

07:22 I'm going to talk about article that the, the maintainer it's a four month bunker wrote an article called how I built a Python web framework and became an open source maintainer.

07:33 And it's this really fascinating article talking about pretty much what he went through.

07:38 He knew that there were a lot of other web frameworks already, but he built this to try to learn the internals of how to build a web framework and then just did it in the open.

07:47 But there's some really great advice.

07:49 One of the things he credits from somebody else called Funky Bob is reinventing the wheel is an awesome way to learn.

07:56 And sometimes what you learn is just how much your existing frameworks are doing for you.

08:01 I thought that was cool.

08:02 - That's very cool.

08:03 - This thing went from just inception to building it to putting up docs and getting extra maintainers in the course of a month in November.

08:13 And now it's still going, but there's one of the discussions in the article is talking about how he tried to put as much in the README as possible right off the bat, like a change log and contributing guidelines and how to work it and everything.

08:29 But the README got huge, So that migrated to a GitHub pages static site generator doc site.

08:36 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.

08:47 So he moved Trello issues to GitHub issues.

08:50 And this process of trying to do a new project in a way that is open and encouraging other people to help out.

08:59 And then at the end of the article, it goes through, I'm not gonna 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.

09:08 And this is like a goldmine of information for people wanting to start an open source project.

09:13 - Yeah, if you're thinking about an open source project or how to make it grow, you're right, there is an incredible amount of tips.

09:20 I mean, there's probably 45 specific things like this helps, this helps, this helps, right?

09:25 So that's really awesome.

09:27 - Yeah, if all this information at the bottom, you could have written a book on this, and maybe you will.

09:33 - Yeah, maybe you will.

09:33 - But thanks, Flormund, for putting this together.

09:37 - Yeah, it looks great, and the framework looks pretty nice as well, I like it.

09:40 I feel like a lot of these web frameworks are like slight derivatives of the Flask API.

09:47 They seem to all be centering around Flask for some reason, but Flask is pretty good, so that's cool.

09:52 Speaking of cool, I heard Kubernetes is cool.

09:55 Kelsey Hightower told us it was, It definitely showed us a cool demo at PyCon.

09:59 - Yeah, I believe anything Kelsey says.

10:01 - Yeah, for sure.

10:02 So Kubernetes is a way to basically orchestrate containers.

10:06 Often you don't want it to run one container, you want to run multiple ones, one with a database, couple web front ends, things like that.

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

10:19 So DigitalOcean, who's sponsoring the show, of course, has just officially publicly released, no longer preview status, their DigitalOcean Kubernetes service.

10:30 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 minutes.

10:41 So it's super easy to scale.

10:44 You take inbound traffic and just access your data over block storage, pass it through your load balancers.

10:50 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 providers.

11:00 So I can definitely believe that DigitalOcean's awesome.

11:03 So anyway, if you're thinking about this, check them out at pythonbytes.fm/digitalocean.

11:08 Get $100 free credit from your users and try your hand at some Kubernetes clusters.

11:13 - Nice. - Yeah, indeed.

11:14 You could even probably serve up Bocadillo on Kubernetes.

11:19 That'd be fun.

11:20 - Yeah.

11:21 (laughing)

11:22 - Cool, well, one thing that we talked about recently, and so this is a little bit of a follow-up, is the maintainability score.

11:29 Do you remember what we were talking about with the maintainability score?

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

11:39 But yeah, it was 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?

11:46 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 things like that.

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

12:10 And it has two types of reports that are relevant to this maintainability index.

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

12:18 It also has a rank from A to F, like a grade score on it.

12:23 So you can run this against your code and ask it, and you can even graph that kind of stuff over time.

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

12:35 - Yeah, that is cool.

12:37 - Yeah.

12:38 So check out Anthony's project.

12:40 I'll link to it, of course, in the show notes.

12:42 And if you can see how well or not well Wiley thinks your app is doing.

12:47 It even has a GitHub pre-commit hook, as all the cool things do these days.

12:51 Yeah, that's a fairly new project too.

12:53 Wiley's only been around for a couple, two, three months or something.

12:56 Yeah, absolutely.

12:57 It's pretty new.

12:58 Would you say it's awesome?

12:59 I would say it's awesome.

13:01 I think so, yeah.

13:02 What else is awesome?

13:03 I kind of like the awesome lists.

13:05 So awesome lists, if you're not familiar with them, are usually on GitHub, but they're basically the readme is filled with links to a whole bunch of other projects of a particular type.

13:16 There's two awesome lists that I came across recently.

13:19 One of them is awesome Python security resources, and the other one is awesome Flake 8 extensions.

13:26 So as far as security resources, it covers tools and education resources, 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:44 Some of these we've talked about and then I also, I really liked that it also included some education resources if you want to learn more about security for your software.

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

14:02 But I like that it has a plug-in system with it.

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

14:16 (laughing)

14:17 It's not PEP-8 anymore.

14:19 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:34 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.

14:41 But so basically it analyzes the quality of your code, right?

14:44 But it only does so much.

14:45 It's definitely a static analysis.

14:47 It's just looking at it just without running it.

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

14:52 Yeah, the extensions, there's a whole bunch of them.

14:55 There's some security ones that actually overlap.

14:59 The security resources in the previous list, 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:12 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:20 It doesn't actually run your pytest.

15:21 What it does is 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:32 If you've converted from unit test to pytest, you might still have some of those other assertions laying around, and this one we'll try - Yeah, one that pops out to me is like flake8-docstrings, which actually checks the docstring code for you, which is pretty awesome.

15:50 Validates this restructured text of your documentation.

15:54 That's sweet.

15:55 - Oh, that's nice, yeah.

15:56 - Yeah, and there's just so many in here.

15:58 - Yeah, and there was, I didn't write this one down.

16:00 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:13 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.

16:29 Well, these are great.

16:30 These are awesome finds, right?

16:31 - Yeah. (laughs)

16:32 - Another thing that's awesome is logging.

16:35 So remember a couple weeks ago we talked about Loguru?

16:38 - Yeah. - Loguru?

16:39 Loguru?

16:40 We don't know.

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

16:44 And of course--

16:45 - I think it rhymes with kangaroo.

16:47 - It does.

16:48 And so just like when we talked about GUI frameworks, we're like, oh, here's like a couple of them.

16:53 And then just people are like, oh, and did you know?

16:55 Did you know?

16:56 So here's another really cool logging framework that Robert Young sent over to us to say, oh, you talked about Loguru.

17:02 You should definitely check this out.

17:03 So this is called fast logging.

17:06 So fast logging is a replacement for the standard logging module, and it's mostly compatible, which is pretty cool.

17:13 But would you guess from the name that it's faster?

17:16 - I should hope so.

17:17 - 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 file.

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

17:33 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.

17:38 - Yeah, nice.

17:39 - Yeah, and it has a bunch of cool features.

17:41 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.

17:53 You can set the maximum file size and rotating, a lot of options on the rotating stuff.

17:58 It'll also, like LogGuru, compress the older file, older log files, which can be 10 X or more savings.

18:06 Like those log files compress really, really well.

18:08 Can do like only log every so often, based on domains, different files, like all sorts of stuff.

18:14 You get callbacks.

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

18:22 So if you're like, all right, I want to log this stuff, but I know that might slow down my app and I don't want any slowdown.

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

18:34 So you can keep stuff flowing right along, maybe in a web request or something like that.

18:38 It's pretty cool.

18:39 - Yeah, yeah, very nice.

18:40 - Yeah, so thanks Robert for sending that in.

18:42 That's a good one.

18:43 Brian, that's it for our official items.

18:45 Got anything else?

18:46 - I actually don't, not right now.

18:47 - Nope, all right, right on.

18:49 - How about you?

18:49 - I have two things that I'd like to just throw out there really quick.

18:53 First of all, I'm doing a live webcast, but it'll also be recorded, over on January 24th at 11 a.m. Pacific time.

19:01 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 there.

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

19:23 YAML apparently had some pretty decent security vulnerability.

19:27 Like, I don't know how many people know, but you can actually just straight up execute arbitrary Python code in a YAML file.

19:35 That's bad, right?

19:36 So like, yeah, so hey, upload your configuration file and we'll just run it for you.

19:40 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.

19:51 Like it was really crazy that the YAML format just lets you embed code into what is otherwise supposed to be a static file.

19:58 Alright, so the warning is that you're supposed to use, what's it called, safe_load instead of load, but they've fixed some stuff to make that, basically make that more obvious with a new version of PyAML.

20:10 So if you're using PyAML, GitHub will give you a warning about this.

20:14 Anyway, it seems like it could actually have a lot of consequences if you don't update that, so check that out.

20:19 Yeah, but also if you're using PyAML, updating to the newest version should fix that, right?

20:24 Yes, you should.

20:25 What's weird is we talked about zero for the way you fix the pie.

20:30 Yama problem is you take a, an official, like I'm just a mess.

20:33 It's like one dot three release and you upgrade it to a beta release.

20:38 So it's like, so you have to install the beta version to not have the security problem, which I don't know.

20:43 Take that for what it is.

20:44 Yeah.

20:44 Okay.

20:45 Come on.

20:46 Bye.

20:46 I'm with people.

20:47 That's right.

20:48 All right.

20:48 Do you have a joke for us this week?

20:49 I don't.

20:50 All right.

20:50 I have a joke.

20:52 This is an oldie, but a goodie.

20:54 It's about Python, which is pretty sweet.

20:56 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?

21:05 Import anti-gravity.

21:06 It turns out, have you done this, Brian, before?

21:09 Yeah, but it's good to bring it up because some people don't know about it.

21:11 Yeah, exactly.

21:12 This is one of the better things built into the Python REPL, honestly.

21:16 And so what it does is it actually opens up an XKCD comic, which is a great joke about Python's packages and libraries.

21:23 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!

21:36 I just learned it last night.

21:38 Everything's so simple.

21:39 Hello world is just print hello world." The guy on the ground says, "I don't know, dynamic typing, white space." The guy in the air says, "Come on, join us.

21:48 Programming's fun again.

21:49 It's a whole new world up here.

21:50 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 what 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 these in of Python. Yep. That's awesome I'm gonna save another import joke that you can do on the terminal or in the rebel for next time or a time after - Okay.

22:20 - But yeah, I really love it that these kind of jokes and humorous things are built in there.

22:25 It's not like Python has been sterilized of all humanity.

22:29 - Yeah, and Anti-Gravity connects Python with XKCD, which is kind of neat.

22:33 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.

22:43 There's another place that I can't remember where it discusses like why it's funny.

22:48 So you can read about things you don't know about.

22:50 - Yeah, absolutely, absolutely.

22:51 - Well, thanks for recording this week.

22:53 - You bet, it's always fun and I always learn something.

22:56 So thanks a bunch.

22:57 Thank you for listening to Python Bytes.

22:59 Follow the show on Twitter via @PythonBytes.

23:02 That's Python Bytes as in B-Y-T-E-S.

23:05 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.

23:12 We're always on the lookout for sharing something cool.

23:15 On behalf of myself and Brian Aukin, This is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page