Python Bytes - #64 The GUI phoenix rises with wxPython
Episode Date: February 9, 2018Topics covered in this episode: * wxPython 4,* Pheonix is now live and supports Python 3 typeshed Coverage 4.5 adds configurator plug-ins Python integrated into Unreal Engine Python 3.7.0b1 : Beta ...means we should be testing it!!! * Releases abound!* Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/64
Transcript
Discussion (0)
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 64, recorded February 7th, 2018.
I'm Michael Kennedy.
And I'm Brian Ocken.
And we're excited to be here with you today.
We have a ton of good stuff that we've uncovered to share.
Very exciting.
Before we get to that, though, I just want to say thank you to DigitalOcean.
Check them out at do.co.python.
There's some really awesome news from them, and I'll share that with you in DigitalOcean. Check them out at do.co.python. There's some really awesome news from them,
and I'll share that with you in a little bit.
But right now, I'm kind of in love with this project that you picked right now, Brian.
Tell me about it.
Well, it's WXPython.
We've heard of this before,
but when we've been talking about GUI development and desktop development lately,
and the WXPython folks contacted us and said,
hey, we are Python 3 and version 4,
codename Phoenix is alive and usable.
That is really cool because WXPython,
there had been a really old version.
And I mean, I think we all can see what Phoenix means
in terms of a project, right?
It's sort of reborn in this new modern Python 3 UI.
Very exciting.
The underlying WXToolkit had been, it also underwent a change project, right? It's sort of reborn in this new modern Python 3 UI. Very exciting.
The underlying WX toolkit had been, it also underwent a change and the WX widgets project has been updated. And then the WX Python on top of all that has been updated. And it's something
that I think I've developed with years ago and sort of discounted because it had an old look,
but now it it looks
nice and people should check it out yeah that was one of my two major major complaints maybe one or
three about the python gui stuff and obviously we're still on this kick and i think it's a good
one actually but the fact that a lot of these ui toolkits look like they've jumped in marty mcfly's
car and like been transported
from the early 90s into your computer. And they got this old fashioned sort of look, they just
looked out of place, right. And so the WX Python stuff looks really modern. It looks like it
belongs on a lot of the platforms, at least Mac, Windows and Linux that I've been playing with
lately. So I'm really happy to see this coming along. The other one, of course, I would love that visual designer sort of tooling in there.
But I'm happy that this thing is coming along.
It's been re-released.
That's awesome.
On their startup page, after you do all the downloads for it, there's a five-line application that you can use to try it out.
And that's pretty slick.
That's fast to get something up and running.
I tried it out yesterday, so it's good.
Very cool.
So I have a little question,
a little tech interview type question for you, Brian.
Did you know that you can define a Python function
and just put triple dots after it and just kind of say,
you know, actually, I don't want to define it?
I did not know that.
I did not know that either.
However, part of my experience of going to PyCascades was to meet Lucas, who gave this
amazing talk from, he's from Facebook and Instagram about how they're doing gradual
typing in Python and how they're adding types to like the millions of lines of code at Facebook slowly.
And this whole process they went through, it's super interesting. I'm having him already recorded,
having going to have him sort of in real time, but the way people experience it on talk Python,
talking about it. And one of the projects that came out of there that I thought was really
interesting is this thing called type shed. Have you of typeshed i have yeah yeah so typeshed
is this place that contains the external type annotations basically the signatures for everything
in the python standard library okay so you go in there and you'll find functions or classes with
with methods and whatnot and you'll see stuff like def visit self common node colon AST.
This is like from the AST module.
And so it'll tell you the type and it says, you know, arrow goes to any, for example,
colon, and then just dot, dot, dot.
And that's it.
And this is a way in which you can define these external types in these PYI stubs.
So it's like a normal Python file that Python can interpret, except for all the methods
are empty. You know, there's a couple of annotations to talk about, sorry, a couple of
peps that talk about the annotations and how this is working and so on. And these are just
the annotations people know. But what's pretty interesting is that this is actually what my
pi uses, like this get repository of what Python looks like in terms of types.
This is what my pie uses the static type checker,
as well as this is what pie charm uses to get all of its magic.
So pie charm is much better than many,
many editors about going,
Oh,
you know,
if you call like what,
right.
You call some method on this other thing,
it returns this other type and you hit dot and you can see all the autocomplete from here.
Where did that come from?
It came from TypeShed, actually.
Okay.
So I don't know.
I thought this was pretty interesting.
And the other thing that is really cool about this, and it checkers to take a moment and document their packages signatures here.
So there's a place to put third party packages like requests or flask or, you know, you name it. If you run an open source project that has a package that people use, you can come over here and put yours
in and then that will be picked up by all the other things.
It's pretty cool. Okay, that's interesting. I'm not sure how they avoid name collision on that.
They basically structure it. There's a third party folder and then I think it's just the next subfolder
is the name of your package, which is unique on PyPI.
Okay, yeah, right.
So it's probably okay.
Okay.
I hadn't heard of TypeShed.
I mean, I knew that you could annotate
your signatures and stuff,
but I didn't know that there's this one place
that's kind of being used as this common source.
So I thought that was pretty cool.
Yeah, and I'm curious about,
so are these Python stub files,
is that the only thing that they're used for, is type?
I don't know.
I had never heard of them before, but apparently.
Interesting.
Okay.
Yeah, it's this new signature.
It reminds me a little bit of what happened a few years ago with TypeScript, where I think it's called Definitely Typed.
I can't remember.
There's now this massive Git repository of all these external JavaScript libraries that want to interact with the typed version of JavaScript.
And so they all have basically, like, there's this similar concept of just the signature descriptions without the implementation in this one giant Git repository.
So this is kind of cool to see it happening in the Python space.
Yeah, definitely.
All right.
One of the things I want to do, I think that Ned Batchelder's coverage tool is super cool.
The same caveats as normal is don't be too enticed with trying to search for 100% code coverage in your tests.
But it's a useful tool in its own otherwise anyway.
But coverage 4.5 just came out, and he added just one new feature.
And this new feature is pretty darn cool.
It's the Configurator Plugins feature, which allows you, you kind of have to read it a bit and get your head around it.
But the idea is there's a lot of people that have different configurations or different run configurations of their code.
And some of the code is intentionally not supposed to run at certain times.
So it throws up honoring all these different requests from people to put new features in.
It has this configurator plugin feature so that you can do your own pragmas ahead of time.
You run a little bit of code before you run the rest of your code, and you can comment out things. As an example, for instance, in the PyTest book,
I had an application that used both TinyDB and MongoDB as two different options. So I would
want to run my test on the whole thing using Tiny and then also the whole thing using Mongo,
but I don't want to, there's some of the code that's only for Tiny and some of the
code that's only for Mongo. It doesn't make sense to run coverage on those parts in those
configurations. So that'd be a great use for that. Yeah, that's really cool because it's really easy
to say, okay, we're at 80% coverage. We've got to keep going. How do we get this higher, right?
But there's some stuff that should just kind of be left alone. And this is a nice way to say, right now, you should not consider this bit of code, because who knows,
maybe it's like some sort of little utility script that you're just throwing in, and you don't
actually want it to be run as part of your package. Who knows? It's pretty cool. Yeah. So you know,
what else is pretty cool is the recent changes that the folks over at DigitalOcean just made. So they've always been the incredible affordable hosting
and basic virtual server space.
They've sort of made places like AWS react in like extreme ways
to try to keep up with them.
So that's pretty cool.
But they just recently more or less just doubled everything that you get for the price.
So for like $5, you get a for the price so for like five dollars you get
a server with a gig of ram and 25 gigs of ssd it's pretty sweet and even includes a terabyte
of transfer which by the way at aws rates that's 93 worth of bandwidth a ten dollars two gigs if
you pay like 20 bucks you get four gigs 80 gigs of ssd couples. It's just crazy some of the prices that they have now over here.
So if you're looking to do sort of virtual server stuff or things like that,
definitely check them out at do.co.py.
They've got some really cool options now.
That's great.
Yeah, definitely.
And thank you, DigitalOcean, for supporting the show.
It helps us keep going.
So we've already talked about, Brian, the fact that neither of us are really into gaming, right? I've been playing a little bit of Formula One, you know, with like the
steering wheel thing. That's kind of a fun simulation, but generally gaming, not so much
with either of us. But I have some gaming news that is pretty interesting. It doesn't have to
do with playing games. It has to do with the creation of games and 3D worlds. So you may know,
I'm sure that you know personally, but people listening
may know that Python is actually used quite a bit to automate and manage and sort of build the
pipeline between all these different tools and all these different people at these massive game
and movie companies, right? Yeah, that's pretty cool. Yeah. So if you've got to go from like Maya
over to some other tool or, you know, you've got these hundreds of gigs of files and they need to be transformed and processed and whatnot.
That's a challenge and a lot of people have built sort of custom versions of that.
So the big news here is that Unreal, the Unreal Engine, which is one of the most significant sort of 3D game engines there is. They're now integrating Python deeply into its sort of processing pipeline,
not its necessary execution.
But they plan to integrate Python into the Unreal Engine for data,
basically for this data pipeline.
That's great.
Yeah, it's cool, right?
So this is from Autodesk.
And they said, hey, we're going to give you a glimpse of what we're doing.
So maybe somebody's built like a model in 3D Max and it's like this super intense, ultra,
ultra fine quality.
You know, every single thing is modeled.
The example I have in this article we're linking to is like there's a motorcycle and the tires
on the motorcycle have those little like, you know, those little dots, those little
sticky pieces of rubber that come out on like new tires where they come out of the mold and they're still like sticking out so they're like we don't
need that in the game right this is going to kill the performance if we actually put every little
bit of these these like knobby things and stuff into the model that ends up in the 3d in the
unreal engine right so they're basically building this pipeline where you can say, in Python,
why don't we just delete all the objects
that are probably too small for people to notice anyway
and just do that automatically?
Do level of details models.
You can, like, merge objects together.
You could, say, actually create a bunch of different motorcycles
by automatically taking the source one
and replacing, like, the material that is, say,
the fenders and the gas one and replacing like the material that is say the the fenders and the
the gas can and stuff to change it from say like a light blue to like a purple shiny motorcycle and
so all of this is automatic so once it's automatic you can you know make a change at the beginning of
the process and replicate this entire workflow which is pretty cool and it's awesome to see
that python's the choice for it yeah very Yeah. So just one more example of people using Python in ways that I had no idea
existed. Yeah. Neat. Yeah, pretty cool. Good job, Unreal. Yeah, good job, Unreal and Autodesk.
They're going to have a brand new version of Python to work with pretty soon, aren't they?
I think we mentioned Python 3.7 last week, but the Python 3.7.0 beta 1 is out, and because it's now beta instead of alpha,
that means the feature sets, I think I might get this right,
the feature sets frozen, and we're just tweaking it,
making sure it's all tight and everything and tested.
But beta means that there's beta testers,
and I was just thinking if it's not people like you and me
in our community that listen to this, who is it?
So I think I'm just putting a call to action out there to go pick a few of the features that are coming up and test things out.
Make sure it works in you and report bugs otherwise.
Yeah, and there's definitely some cool features in there.
We talked about data classes last week, that being in there.
But there's actually a bunch of changes.
And it's one of
these things. Speak now or forever hold
your peace. It's going to come out in June.
So here's your chance to
test it. I was going to take a look at the break
point feature and the data classes and
maybe a couple of the others and
give it a whirl. Nice. So do you know
if there's easy ways with
things like talks and stuff to go ahead and run
your tests on Python 3.7? Yeah, of course.
Talks you can set up 3.7 as
one of the Pythons to
test everything. Yeah, that's one of the ways
I'm going to test this. I've got to
make sure that there's new versions of
PyTest as well, and I want to make sure that all
combinations of Python,
all recent versions of Python and
PyTest work with all the demo
code I have in my book.
And doing that manually is just too much work.
So I'll use Tox for that.
Yeah, that's a complete nightmare.
Yeah, tell people really quick.
I know some people know about Tox, but not everyone.
So tell people where does Tox fit in?
Because I thought you were a PyTest guy.
What's up with us testing the Tox thing?
Well, Tox is sort of like a top-level scripter thing, and I'm totally going to get it wrong.
But the way I use it really is to pick multiple configurations.
You can have multiple combinations of different libraries together or configurations of your system and test them separately. Yeah, nice. So you could say test on PyPy and on CPython
and multiple versions of either of those
in a single test run, right?
But the system will configure the interpreter
or the runtime for that, right?
It goes out and you can turn off or on all these features,
but by default it takes your, like let's say a package
that is a Python package,
and it runs its setup function to create
an installable Python wheel, I think. And then it creates a virtual environment, installs your
package and all of its dependencies, and then runs the tests on it and then reports on that.
And then it does it again for however many different configurations you've got set up.
So for our final item, the one that I want to cover is similar.
You were talking about a new release of Python
coming out in beta.
I want to just sort of hit a whole bunch of other things
that were released that were pretty interesting
on a couple levels.
So first of all,
I think some people use this web framework.
It's called Django.
What do you think, Brian?
Yeah, quite a few.
Yeah.
So they just announced that they had a security release to fix some issues around authentication
and basically the login infrastructure in Django.
So if you're using 2 or 1.11, you may want to check that out.
So there's been like, you know, here's the testing thing.
There's been a regression.
There was a problem.
It was fixed.
And now it's unfixed.
It's fun when problems unfix themselves. So the release is with the unfixed one?
This puts the fix back. Oh, okay. And then two more around Python 3. One is Python 3.4.
There's a security release there. And one is Python 3.5. There's also a security release
there. So respectively, the versions are 3.4.8 and 3.5.5. And there's also a security release there. So respectively, the versions are 348 and 355.
And there's apparently some problem with this internal bit called libxpat. As far as I tell,
it's like an XML parsing library. And there's some kind of issue with that. That sounds not good.
Like people could send you bad XML and bad things happen. So be aware. And just a reminder to
everyone. And if anything like this happens in Python 2 shortly,
there will be no fixes.
You're just going to have to live with it
after it goes end of life.
So it's good that they're fixing these.
I don't know when 3.4 is gone, end of life, right?
3.3, I think, is now out.
Anyway, the final one, I said at a lot of releases,
is channels. So these are Django
channels. They're pretty interesting in that they add like an asynchronous way to write Django,
WebSockets, and these types of things. Actually, I had the guy behind this on TalkPython,
and I linked an interview there. But this is sort of a complete rewrite. This is channels 2.0. It's a major rewrite. And most notably, Python 2.7,
even Python 3.4 are no longer supported.
They're fully legacy Python.
They're out.
It's 3.5 and above is all this works on.
Okay.
So I suspect some of that might have to do with Django 2,
but also it being this async thing,
maybe they use the async and await keywords
and it just doesn't work in 3.4 or below.
But yeah, it's all pretty cool.
A bunch of new releases.
So if you're using these and want to check them out, do.
That's it for our news this week.
Brian, what items do you have to share?
Well, I've got a couple exciting things.
Yes, you do.
I had submitted five talks to PyCon, and one of them was accepted.
Congratulations.
That's awesome.
It's a talk.
I'm going to do it together with Paul Everett from the PyCharm team.
So it'll be PyCharm and PyTest, and that'll be fun.
That's going to be really, really fun.
The two of us also are going to do a webinar coming up on the 22nd of February,
and a similar topic, but a little bit more advanced. So we're going to dive into
how to productively and effectively use PyTest within PyCharm.
Oh, that is really cool. You know what I'm doing right now? I'm going to register
after I'm inside. That'll be really fun. And then all of these, of course, get recorded
afterwards, right? So it's typically an hour Q&A, lots of fun. But if you can't make it live,
you know, you should still register because then you'll get a notice that, hey, the recording is
out. And I suspect we'll let people know when your recording is out. Like maybe this week,
I might let people know my recording is out. I registered for yours and I got a, I didn't
watch it, but I got an email saying, hey, it's up. So I got to go, I started watching it this
morning. Yeah, that's cool. So I did recently, I did a webcast with the PyCharm guys as well.
Paul was sort of there as the emcee of the whole experience. And what I did in mine was I said,
let's learn how to play with MongoDB from Python. So let's take PyPI and recreate the data access
layer of what PyPI might look like in a document database using Mongo and Mongo Engine, stuff like that.
It was lots of fun, so you can go check out that recording.
We link to it in the show notes.
And I suspect around February 30th, you might have a similar one.
Just a small toy project there, recreate PyPI.
And I'm a little disappointed because I used Faker.
We talked about Faker before, right, where you can create fake data.
That thing is glorious.
It needs a few other features, which actually I'm thinking of doing some PRs for
to add them. But I created sort of 100,000 fake PyPI packages, and they have kind of some kind
of data. So now what I'm working on is a system that will let me entirely download every piece
of data from PyPI and then model it in the database so that for other projects, like I'll have this like basically corpus of all of PyPI.
Okay.
So for the next few weeks, if PyPI is slow, it's your fault?
Yeah, you can blame me.
I'm sorry about that.
Exactly.
Or I go over my bandwidth limit or something like that.
Yeah.
It was really interesting so far that I've gotten into it.
Good job. Yeah, cool. Thanks.
That's it for this week.
Thank you everyone for listening. Brian, thank you for
sharing this with us. Alright, thank you.
Talk to you next week. Yep, bye.
Thank you for listening to Python Bytes.
Follow the show on Twitter via
at Python Bytes. That's Python Bytes
as in B-Y-T-E-S.
And get the full show notes at pythonbytes.fm.
If you have a news item you want featured, just visit pythonbytes.fm and send it our way. We're
always on the lookout for sharing something cool. On behalf of myself and Brian Auchin,
this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and
colleagues.