Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 138, recorded July 3rd, 2019. I'm Michael Kennedy. And I'm Brian Akin. And this episode is brought to you by DigitalOcean. Check them out at pythonbytes.fm slash DigitalOcean. More on that later. Brian, how you doing? I'm good. Been recording a lot. Yeah, recording a lot and trying to survive a work move, huh? Yeah, I'm not looking forward
to half an hour drive. Yeah, a work move is like when you get to move and your commute changes, but you don't get any say in it, right? Yeah, exactly. Yeah, I don't know if people know, but traffic in Portland and in the Northwest, it's rough, man. Yeah, but I mean, I lucked out. So for like nine years, I had a 10 minute commute. And I know a lot of people have worse commutes. Yeah, my commute is really rough. My studio area is like above my garage and the garage is detached.
So I go across the sidewalk and periodically there's like a squirrel or something that will startle me a little bit. And that's like a rough commute for me. Yeah, I'm just kidding. No one should feel sorry for me on that regard. That's awesome. Nice. All right. Well, speaking of keeping everything like legit and keeping surprises out of it, that's probably where we should start, huh? Sure. You want to jump into the first item? Yeah, yeah. Flightgate,
let's do it. Okay. I use Flightgate all the time. I actually put it on almost every project to make sure that I'm just not doing something stupid. So it does a whole bunch of different, I think we've talked about it before. But one of the things that I came across, this was submitted by Florian Dolitz, I think, is Flightgate Comprehensions, which is a plugin for Flightgate. You just install that
also and it'll run automatically. People are used to list comprehensions, but there's a whole bunch of other things like dictionary comprehensions and things like that. Set comprehensions, yeah. Generator expressions, all these things, right? Yeah. There might be some old code that works fine, but maybe it would be easier to read if it was changed. So this is just some static analysis for your code to
check different things to, you know, make your code look nicer. Awesome. Like some of the warnings are unnecessary generator. Rewrite that as a list comprehension or unnecessary list comprehension. Rewrite it as a dictionary comprehension and interesting stuff along those lines. So yeah, that's pretty cool. I'm going to hook it into all my projects. I haven't tried it yet to see if it's
helping me at all yet, but it looks like a fun thing to add. Yeah, there's some nice little cleanups here and I'm just kind of always amazed at how similar the comprehensions are, but how different the resulting outcome of them are. You know, especially with list comprehensions, square brackets, and generator expressions, parentheses. One is like this lazily evaluated generated expression that can
be used once. The other is a list, right? But it's like you just round the edges a little bit on the symbol and that's it. Yeah. And I always forget that set comprehensions are a thing. So nice, nice. Yeah. So these are great. I feel like these are in the category of Pythonic code that a lot of folks don't know about, don't use and so on. Right. They're like, well, in C++, what I would do is I would write a for loop. And so they have four in loops in Python. So I write that as like, actually,
we have these comprehensions too. You don't need that. So pretty cool. Anytime I can move code reviews out of personal opinions and into a static analysis tool, it just makes the team smoother. Yeah, absolutely. I think it's really interesting psychologically that people, developers respond differently to criticism from a robot than they do from a human. Yeah. I mean, it's like a compiler warning or something at that point.
Exactly. It's like, well, CI says you got to do it. So we all agreed that this is how it's going to be. So we do it rather than like, well, that's the guy that's always picky and always says to rewrite my code and it's not Pythonic. I don't want to invite him to lunch anymore. It's like somebody will pick up the torch and be the one person that's always telling other people that they're, they need to change their code because of style. And that just gets old. So yeah,
let the computer do it. Exactly. And it's more consistent anyway, no matter how anal the person is the computer is more so. So this next item here is something that is near and dear to my heart. We've covered it before when it first came onto the scene, but it's now really ready to go. Now I want to just set the stage here that I think, you know, we've talked about this before. I can't remember
where, but we've spoken about before that basically, you know, Python's growth is incredible. We've talked about that a bunch, but fast becoming one of the most popular languages, but there's really three areas in my assessment where Python could be, you know, it's weak or it could be dethroned or it could in the words of Russell Keith McGee actually be an existential threat to the longevity of Python. And those are a proper way to
build mobile applications with Python. I know we have Kivy and we have some stuff from Russell stuff as well. Right. But those are like sort of, well, we'll get it working. It's kind of proof of concept. It's not like a visual designer drag and drop. Here's how you push this button to publish the app. So, right. Like there's not really a proper way to build mobile apps for Python. That's an existential threat.
Number two is I would like something like the Slack app in Python. Build that. Yeah. Good luck with that. Right. Like probably not. So there are ways to do stuff like that, but it's always either like some kind of kludge or it's, yeah, you can build it, but it's going to look like from 1994. Nobody wants that. I mean, Qt's pretty good. Qt is pretty good. Yeah. Qt is pretty good. I'm thinking, you know, TK Enter. It's like,
it's definitely showing its age, right? For example. So yeah, those are great. And so like, GUI is probably the least existential threat of these, but it's very clear, closely tied to this last one, which is sharing your application with end users. Somebody who doesn't care whether or not your program is written in Python, they would just want to run your program.
How does that happen? Oh yeah. Yeah. That's a problem. And you, what was really interesting was there's a while ago I talked about Gita Van Rossen being interviewed on, I think it was the AI, the MIT's AI podcast. It was a super interesting interview and a lot of great stuff that he said, I think they talked about it there with him. If it wasn't there, it was him being interviewed somewhere else. And basically they said, well, how do you feel about
this deployment story? It doesn't seem like a weakness. And Gita's thought was, well, you can really use a lot of the Linux package managers to solve a lot of these problems. Like if I want Python there, I can apt install Python three. If I need to get pip, I can apt install Python three dash pip and so on. And it was very clear, like his whole thinking about what getting an application to a user meant was getting it properly set up on a server or like a developer gets the tool set up on
their Linux dev machine, which is all well and good. But you know, the most important thing is how do I give an icon thing to a person on a Mac or on windows? They can double click and then their thing runs. You know what I mean? Yeah, sure. Sure. I mean, for all the people that need a dev tool on Linux, there are a hundred more, a hundred times more who need an application as an end user. You
know what I mean? Okay. Yeah. So if we want to get, if I want to get something like say, if I've created some data science tooling and I want to give that to my team, I would like to say, here's like a DMG or an MSI installer, you double click it and then you run. I don't care what version of Python you got set up or anything like that. Right? So I think that's the third problem is like, how do we get
like end applications users? And the reason I think it's partly, it's kind of this chicken and egg problem. I feel like partly the reason it's not got a lot of attention in the Python space is because it's so bad. It's like so nearly impossible that people just generally don't do it. So there's like not a lot of demand for people creating those types of applications to get them out because it's like,
why would you use Python for that? It's like, doesn't even make sense. Right? There's Pi installer, but it's also good, but it has some limitations. And so the thing I want to cover again is Pi oxidizer. And the reason is it's now officially released. It has its first release. And I had been watching the GitHub repository, you know, as like, you can say, go watch this repository. And my email just like blew up. Like I couldn't, I just go and like was constantly cleaning up like pull requests,
issues, all this kind of stuff. Like people were just going crazy on their repository. Okay. It's just got a ton of traction. So that's out. And I just want to kind of highlight some of the stuff. The guy who created it, gosh, Gregory created it. And he's done some awesome stuff. He wrote a really nice article, which I'm linking to here. And it covers a lot of the reasons why you would want it.
So at PyCon 2019, like I said, Russell Keith McGee said, basically, this distribution problem is like a potential black swan event for Python, right? I still don't know what that means, but sure. An unseen super negative thing coming out of the blue that's going to dramatically disrupt it somehow. I don't know if I would call it that. But I definitely think that distribution is like
a reason people would not be using Python first term. I don't know if I see it as like this negative sense, but I definitely see it as a, it could be so much more, right? Yeah. I mean, Python's so great everywhere else. It'd be cool if it was great there too. Exactly. Why is it not good there? Yeah. Gregory said, basically, I'm going to create this project called PyOxidizer and it uses Rust to bundle up your Python code into an executable application. A .app thing on Mac, a .exe on
Windows, and a statically linked binary executable on Linux. So it works on all the different platforms. And what's cool is it takes all the dependencies you have. So if you depend on say pandas or whatever, right, it'll bundle that up. It bundles the version of Python that you build it against, right? So you're guaranteed you'll have 3.7 no matter what system you put it on, if you build it against 3.7.
Okay. And what's really interesting is the way it works is it builds a single executable and then your Python code is loaded from bytecode in memory. Oh, wow. Right? So like it actually creates your Python files. It creates PYC files. So pre-computed PYC bytecode and then loads that out of memory. So it actually runs faster than if you ran the code, it starts faster than if you ran the code in regular Python. Okay.
Some tools care about starting fast. Some don't, right? Like a website doesn't really care about starting fast. But a command line thing... If you're going to write an editor, you want it to just pop open. Exactly. So the other problem with the other ways in which this was done was they would basically zip up your Python code and maybe unzip it and then try to run it from there in memory thing. So you also kind of leaks your source code a little bit, right? Yeah, I guess so.
So if this is embedded as a binary, it's less obvious for people to go poking around that this is Python code that they can go read and mess with, right? Like technically, I know it still could be messed with. But it's not like, well, here's the directory of Python files. What is this doing in my applications route? You know what I mean? Let's go play with those, right? So this is pretty, there's just a lot of interesting things here. The article that Gregory put out announcing it,
it's pretty broad and it's really compelling. So it seems like this project is really taking off. I definitely think it would change the landscape if we had something like this legitimately working well across the board on all the OSes. I think it would actually drive people to build more GUI based apps because there would be a much more clear path on how to get those applications to end users, not just developers and developer tools and servers.
Yeah. Cool. Well, anyway, PyOxidizer, it seems to be catching fire and that's pretty awesome. Yeah, it is cool. I like it. All right, what you got? What's the next one? Well, speaking of sharing code, one of the things that people do is not with end users, but with just other developers is to take a script. You've got like just a, you know, you created a script, a little module or something, and it works on your machine. You want to share it
with other people. Even that there's a little bit of a barrier between writing a simple script and packaging it up properly and getting that running. So it's one of the things I'm actually working on a write-up, trying to do a write-up of all that with experimenting using it with using Flit and pytest and Tox and Coverage to make sure it's well tested and structured well and all of that. That's cool. Because you were, before you were sort of a fan of creating a source directory for your
packages and, but that ran into trouble with like Flit, right? Or some Flit or Tox? That's the thing. With Coverage, you want to be able to, I want to be able to test or run against the installed version, not the local version. So I want to do all of the packaging, install it into an environment, and then run the test against that. And that was hard to do. I thought it was hard to
do. And a lot of people were recommending using an intermediate source directory to hide the local code from Tox and from, well, not really from Tox, but from Coverage and pytest so that you were really loading the installed one. I didn't know there was a thing here. And I'm highlighting a feature of Tox that's called ChangeDir. And it's really simple. You just put this in your test environment lines in Tox, in your ToxAny file, and just say, change the directory to like my test
directory. And then, voila, you can't see the top level source code anymore. Oh, that's cool. Problem solved. So I've got a longer explanation. I'm going to talk about this on, I have on episode 80 of Test and Code, which will be out by the time this is out. But I was amused because I'm walking through an example. And I'm trying all these things to make sure they work. And the example project I built was a markdown converter using regular expressions.
And I thought this was really funny because of the news that came out recently that Cloudflare went down because of a regular expression. A single regular expression. And Cloudflare is like the intermediary to so many applications out there. That's bad. Big chunk of the internet not working because Cloudflare was pegged on one regular expression. I don't even know how to do that. I don't know how to make a regular expression that...
I do simple regular expressions. So I don't know how to do something that's quadratic in nature. But I thought it was funny. Mine tell me they're not working right away. But they say that too frequently. Yeah. Why is this not finding the match? Oh, well. Since I thought that was... I was using regular expressions and I thought it was funny that somebody else reminded me of that Mel Brooks quote that it's tragedy when it happens to me.
It's comedy when it happens to you. So I'm laughing at Cloudflare, but I wouldn't be laughing if I was working there. Yeah. If your pager was going off at three in the morning, the humor would be entirely sucked out of that situation. Yeah, that's rough. Yeah. Before we get on to the next one, let me just tell you all about Digital Ocean. I try to highlight one of the features of what they've got going on. Like I said, many times our infrastructure
runs on Digital Ocean and they do a great job. So one of the things you might not want to deal with is setting up a Postgres server, backing it up, setting up the right scaling infrastructure
and all that. So Digital Ocean has this great feature where you can get a managed Postgres database as a service, which solves a whole bunch of problems like figuring out what the optimal database infrastructure footprint is or scaling it as your app grows or creating highly available and failover infrastructure, all that kind of stuff you want, but you don't want to deal with it or deal with like when the pager goes off because it stopped
replicating or it wouldn't scale or whatever. Just go to Digital Ocean and check the box to get your managed Postgres database and let them deal with it all. So that's really nice. Runs right there in that data center. So you're all good. Check them out at pythonbytes.fm/Digital Ocean. They're big supporters of the show and highly recommended. All right. So this next one, Brian, I think has some pretty interesting possibilities and maybe ties back to my item that I spoke about
before creating like a new type of apps or opportunities for more apps. Now it used to be if you wanted to have some kind of communication, you'd have to go install like weird plugins into your browser. So you could do, I don't know, some kind of real time chat or video communication. But recently, these things have just been working all on their own, right? Things like Zencaster and whatnot. Now it could just do like live communication in the browser. And that's because of WebRTC and ORTC.
The Web Real Time Communication is an open project that provides browsers and mobile apps real time communication. And then the open ORTC one is basically a similar style of communication. Okay. The item I want to talk about is this implementation for Python that uses asyncio. So you can write Python applications that then communicate with other things like browsers or mobile apps and whatnot that use WebRTC. Oh, cool.
Yeah. So it's called AIO RTC. AIO is for asyncio and then RTC, well, you know, for the protocol. So it's pretty cool. It follows pretty close to the JavaScript counterpart, which is how you would do it in the web. But it uses a lot of Pythonic constructs like the popular JavaScript ones use promises. So this AIO RTC uses coroutines, which is cool. And events are emitted using the PyEventMeter, which is all good. The main ones, like the main one is if you want to explore these communication
protocols are all baked into the browsers and they come in native code. But if you want to explore like a more understandable version, a more hackable version, this one is all just in Python, which is pretty cool for understanding how it works. They also talk about some of the kinds of apps you could
build, right? So like you can create some new things in the Python ecosystem. For example, you could build a server handling both signaling and data channels and apply like computer vision to the video frames using OpenCV like in real time or something cool like that. Oh, that'd be neat.
Yeah. So people doing fun stuff with video communications. If you want to write a Python application that can participate in that and you want it to be nice and modern using async and await and asyncio, well, this is a pretty cool AIO RTC. Yeah. Yeah. Speaking of communications, you got another one, right? This was a listener's suggestion and I can't remember who submitted it, but I think it's, and they even have the, it's called a prize. I think that's how you pronounce it. Is that right?
A prize. Yes. To inform or to tell someone, to make one aware of something. They've apprised me of the situation. Really? Yes. Okay. Carry on. Sorry. Okay. So a prize is for push notifications and their tagline was push notifications that work on just about every platform. It's kind of a shim layer to put between your app and multiple notification services. So it sends notifications to things like, Telegram. They say Telegram push bullet. Never
heard of either of those Slack and Twitter. Yes, I have heard of those, but also things like a discord, getter mail gun matter. Most Microsoft teams, even sending SMSs through Twilio or Nexmo that's supported email notifications supported for that. Some things that are, you want to just email people, but if your server's on fire, you might want to send an SMS to somebody. Yeah, that's cool. It's really cool. It looks pretty neat. The API looks nice. It looks like it'd be pleasant to work with.
So I think this is a good one to highlight. It looks neat. Yeah. Some of the stuff that stood out to me is Growl and Windows notifications. Do you know what Growl is? So Growl is, I don't know if this is the way it still works in macOS, but you know, the little toast notifications that come up in the top right in macOS? Oh yeah. Yeah. Yeah. Growl does that. Oh, okay. But you might have to have a little daemon installed. I can't remember if it natively
talks to Mac. I don't think so. I think Growl is like before that was built into the OS, but basically it does that. And then Windows notifications like similarly, but instead of being the top right, they're in the bottom, right? So they're not at all the same thing. And it also supposedly supports matrix. So I don't know if that texts Keanu Reeves or Yeah, exactly. Yeah. I know Kung Fu. Okay. Sorry.
Yeah. No, this is really cool. If you've got to communicate with Gitter, if this, then that, all those different things, you know, Cisco teams, Microsoft teams, all those, rather than integrate with all of their APIs or Twilio or whatever, just like bring this in as like a facade over all that. It's great.
Yeah. So this last thing I want to talk about is a new web framework. And I feel like the web in Python is getting really interesting and also a little more hard to choose the right thing to do because it used to be, oh, Django Flask. There's Pyramid also. I like Pyramid. And there's, there's a few others. There was Cherry Pie that's not used that much anymore. So I guess I'll choose between those three, right? Like that was kind of like the end of the thought, but now there's like
hundreds like of little things, right? There's black sheep that we talked about. There's mace tonight and there's Jepronto and there's, well, there's WebSana as well. So WebSana is a new framework. And I think it's super interesting because it, you know, it kind of brings some
more beginner friendliness or CMS friendliness to some of the micro framework story. So we've got another way you might break up the web framework thinking process as well as I want an app that's kind of like, I've got to work the way it works, but I can block in the, I can like slot in these big blocks and have stuff I want like Django. So like I can have an admin back in where I just like have like an Excel, like view of my database if I want that, for example. Right. But if you want to
not work the way Django works, well, too bad you work the way Django works. That's how you use Django. Right. On the other hand, you could use Flask or Pyramid where it's kind of like, well, here's how you process a request. Whatever else you do, that's on you. Right. It's up to you. So a lot of people kind of like that more fine grained stuff like, well, I think I'll use SQLAlchemy here and I'm going to
use like this for managing passwords. And here's how I do my users and email and all that. Right. You get to choose all those little bits, but then you got to choose all the bits and build with it and so on. So this WebSona framework is built on Pyramid, SQLAlchemy, and obviously Python 3, but it adds a lot of the features people might choose Django for, but in like a super modern and cool way. So I really,
really like it. Their description is WebSona is a full snack Python web framework for building web services and back offices with admin interfaces and user signup processes. That's good. Yeah. So it says, well, they say, well, when should you use it? Well, it's focused on internet facing sites when
you have a public or private signup process and an admin interface face. And the sweet spot includes custom business portals, software as a service products, which are too specialized for off the shelf solutions, read WordPress, Squarespace, like all these things you're like, oh, you could use that. Well, for like 80%, you could use that. Then, then what, then where do you go? Right. So WebSona can now be a place that you might go for that. Cool. This might be take off. Yeah, I think it really
good. And so they talk about, they're focused on like core business logic. So you can, you know, they build all, have all the building blocks. Like you want to sign up with Google with your Gmail. Yeah. You just like put that in there and it just, now you can sign up for the, your app with Gmail. It's nice. You can get started real easy. Lots of docs. Yeah. It's just all about being productive. So they have a whole bunch of infrastructure built up and just like kind of fill in the pieces.
It's a little more Django-esque, but then like raw pyramid is, but it's kind of nice that you have this blended option. So I think it's looks really promising. They have a lot of cool things like asynchronous task processing and other stuff like that, that really makes it feel like pretty modern and cool. Yeah, definitely. Yep. It looks like it's tested using pytest also. Yeah. It's tested using pytest. It's deployed using Ansible. Let's see what else. There's a couple of things like,
yeah, that is super cool. It automatically comes with the top OWASP top 10 security vulnerabilities limit, like restricted. So like they figure out what are like the top 10 reasons websites have security problems and they built into the infrastructure by default to block all those like cross-site scripting and whatnot. They have asynchrony built in and they even comes,
it even has a IPython notebook shell. So instead of just having like a grid view of admin stuff, I can type in, they're like, oh, well, if you need to do admin tasks, like log in and just fire up, you know, Jupyter on the backend and just start like manage it like that way. Right. So that's like, all right. So it's like a web shell to your, your server, keep that super locked down, but you know, still pretty awesome. So there's a bunch of like really interesting ideas here that I think are
quite cool. The documentation is pretty thorough. It even includes like, okay, once you get this stuff working, how do you deploy it somewhere? Yeah, exactly. This is quite new, but it also looks really promising to me and I hope it, I hope it takes off because I feel like this is like a really nice modern take on what a modern Python web app framework should look like. Yeah, cool. All right. Well, that's it for our main topics. Brian, you got something you want to share with us
just quickly at the end. Yeah, I was going to mention, so I did, we mentioned in my move, the move at work has been caused my schedule to be crazy. And I don't know when to interview people. If you've been paying attention to testing code, the episodes have been kind of solo episodes lately because I don't have to schedule myself. It's just whenever I can do it. And later on in July, things should settle down. And so if I've bugged you to do an interview or you've asked me
and I haven't gotten back to you, get back to me again and we'll schedule that. So that should go on. Yeah, right on. You're doing a great job with testing code. There's a lot of stuff been coming out nice and steady and a lot of good shows there. All right. Thanks. How about you? Well, I just released another course that I've been working on for a couple of months on and off, and it's called Building Data-Driven Web Applications with Flask and SQLAlchemy,
speaking of micro frameworks. So I had a similar course on Pyramid and a lot of people said, hey, Pyramid's awesome, but we really need to know Flask because that's what we use our company or that's what I'm trying to understand for a job or whatever. So I'm like, all right, well, let me go and build the Flask version of this course. So basically the idea is we spend about 10 hours recreating PyPI.org from the ground up with Flask and SQLAlchemy.
Oh, that's cool. Yeah. I'm going to have to check that out too. Yeah, absolutely. So people can check that out. Links from the show notes are just training.talkpython.fm. That's the latest course. And you know, no time to rest. As soon as we're done recording here, it's time to start the next, continue on the next one I'm working on. So I'm really excited to have
this out. I think a lot of people will appreciate it. And it was really fun to write because you got to explore like a lot of these ideas we were just kind of just talking about. Yeah. I'll be hopefully working on a course here pretty soon too. I'm very excited about that. Yeah. I'm not really sure we're ready to share what the topic is yet, but it's going to be in high demand and very popular. Yeah. I'm looking forward to it. Yeah. Complete secret. Nobody will know what it is until it shows
up. Yeah. Computer vision, IoT probably, but I'm not going to... Yeah, maybe. Yeah, sure. Or something else. Probably. Yeah. So speaking of jokes and sarcasm, a SQL query goes into a bar, walks up to two tables and asks, can I join you? I really like that. Yeah, it's pretty bad, but... That's good. It's a good one. Yeah. So I don't have a joke, but I saw this on Twitter and I tracked up. I did watch this. Yes. The reset procedure from GE light bulbs. It's so funny.
These are smart, in quotes, smart light bulbs. Yeah. And you may have like paired them to your device, but then you lost your phone or you gave the light bulbs to your friend. You're like, well, how do I reset my light bulb? Right? Yeah. Because you can't just like turn it off and turn it on because that's what light bulbs do. So
you have to do something else. And this procedure that they've got is hilarious. And it's like, turn it off for five seconds, then on for eight seconds, then off for two seconds, then on for eight seconds. And if you go through this like five times... It goes on and on because like, what if somebody accidentally turns it off for five seconds, on for two seconds, on for eight seconds, then off for eight seconds, but didn't mean to reset
their bulb. You got to do like three more rounds of that. It's insane. Yeah. So yeah. Yeah. You will link to the video for that. At the end, it's like, if that didn't work, maybe it's an old firmware version. Try this other, even worse procedure. Awesome user interface experience. So I love it. What do you do when like the only interface you have is like power on power off? This apparently is it. Yeah. But the register like noted that you
could put a hole in it and people could poke it with a like clothespin or whatever. Oh, you mean like my router and like all these other normal pieces of technology? Yeah. The reset button. Exactly. Yeah. Maybe they don't want people poking metal things into bulbs because it's like too close to poking it right to the socket. Because people are always poking metal into light sockets. Yeah. Exactly. Exactly. All right. Well, yeah, people can go check this out and it's intended to be
serious, but it's actually kind of funny. Yep. All right. Well, thanks a lot, Michael. You bet. Thanks for being here. See you. 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