Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
your earbuds. This is episode 287, recorded June 7th, and I am Brian Okken.
I'm Michael Kennedy.
It's good to talk to you, Michael.
Yeah, good to see you again, Brian.
Yeah.
Again, we've got our wardrobe matching our background here, which is fantastic.
Yeah. We like, you know, texted each other in the morning to make sure.
Feeling purple. I'm going to get a new shirt. No, it's great. Good to see you as always.
Lots of fun Python things to talk about here.
Yeah. Yeah. Well, let's jump into the first one.
The first thing that I want to talk about here is distributing Python applications.
Now, this is a little bit in the Python GUIs side of thing, something you just can't get enough of
in terms of like, hey, could we have more ways to do this that are like awesome?
How about if we had ways that were automatic?
Yeah.
So I want to talk about this thing by Brent Bola-Bregretz called AutoPy2exe.
And it basically does what it says right in the name there.
Converts a .py file to a .exe using a simple graphical interface.
Now, this GitHub description is a bit of a Windows bias because it will also create it to Mac apps as well,
to .app files. So it's not just a Windows thing.
Cool.
It's pretty popular. It has 2,000 stars, 400 forks. And what it is, is a UI on top of things like PyToApp or PyInstaller,
specifically PyInstaller. So what you do is you fire this thing up and out pops this user interface
that if you're watching the YouTube stream, you can see there's a user interface here.
And it just says, pick the starting Python file for your application. And you can say, what do you want the output to be?
One file or one directory?
Okay.
I think we all want it to be one file, probably generally, but maybe a directory. I don't know.
What else you're going to, maybe you want to do some other things there.
But what I did is I tried this against my URL by little appy thing, which let me pull that up.
This is something I built a while ago with rumps. It's fantastic. Ridiculously uncomplicated menu bar apps or something like that for Mac.
And all it is, is a little thing that goes up in your Mac bar and it has like, you know, sluggify text or trim it or lower cases.
It's just, I'm constantly taking names of like file names and turning them into something I could put as a URL or like a title of a video or something and turning it into something that would be a good URL.
So that's what this little app is for. But here's the thing is it's a Python app that runs in the menu bar on my Mac with no terminal view.
And I wanted to be able to distribute it to people. And so the way you get it is you just download a zip file, which is just the zip up dot app executable.
Right. So I had done a bunch of stuff with the setup and all those kinds of things with pi installer to build this.
So my test case was, well, let me take this auto pi to exe thing and just point it at that and see what happens.
And what happened was good things. It was really interesting.
There's an app dot pi, but there's dependent Python files that it uses. I mean, I'm not a beast. I don't write my entire application in one file.
Like there's other things broken apart in there and that gets bundled up and it somehow discovered that all those all in.
So I just picked the top level file and it found the dependencies, you know, the requirements dot txt type dependencies and so on.
And it created a dot app file that as far as I could tell ran just fine.
That's cool.
Isn't that cool?
Yeah, I like it.
You can decide if it's a window based application.
So hide the console, which is what I said because I want it to run in the menu bar.
But if it was a console based app, but you just wanted to distribute it as a single thing with no Python, well, no Python requirements.
You could create a console based app.
You set the icon.
You can add in additional files.
So if there's like, you know, JSON configuration files or YAML files or images or something like that, you need to take a long, you can configure that there.
And then there's an advanced section that expands out to be like pages of stuff that I don't remember.
Same thing for settings.
And then you just click the big convert to pie to EXE button and you get ironically not an EXE, but a dot app file.
And there you go.
That's cool.
Isn't that cool?
So for people who are playing around with this, I think they, you know, they even have, they must be listening to us here.
They even have a little animated GIF of how this all works right on the GitHub.
That's pretty good.
So if you want to see how it works, I guess there's not a whole lot, but you browse for the icon.
You go in there and you check off some things and then you just hit build.
And it takes a little while, but you know, that's pie to EXE.
That's how it goes.
And it just sits there and it cranks away for a while, bundles it all up and yeah, got a little executable.
So if this is something you want to play with, but you're like, ah, it's kind of a real pain to go and figure out, you know,
all the, the setup pie commands in order to get it to do the pie installer commands and whatnot, then, you know, you can definitely give this a shot.
I think it's pretty neat.
I think with mine, I didn't use pie to installer.
I think I use pie to app.
Yeah.
That's what I used.
So pretty neat.
Yeah.
Check that out.
Nice.
I think people will find it helpful for ways to distribute Python apps.
Yeah.
And I like that it looks pretty professional looking.
And then also, especially, I mean, especially with internal, like internal company stuff, there's, that happens a lot where you want to share something.
Yeah.
Around.
Yeah.
Like just download this and run it.
Please don't ask me how to set up a path so that your Python, that's not Python three, three.
Yeah.
So whatever, right, is the one that runs it.
Nobody needs to know that it's Python underneath.
So.
Yeah, exactly.
So.
Oh, cool.
I like it.
Oh, one other thing, by the way, it's a GUI application.
It's self-written in Python.
So you may wonder, well, what is it doing, right?
Maybe it's bundled itself.
Obviously, that'd be very meta, right?
Like if autopy2xc could deliver an autopy2xc itself, that's obviously lovely.
It reminded me that I have Chrome installed when I ran it.
So what it does is it runs something in the background, then it fires up Chrome, which
becomes the UI in this kind of Windows looking Chrome window.
And it's not quite an Electron app, but it's Electron in a style.
So anyway, it's an interesting little UI app itself.
I'm not sure what it's doing, but it works.
Nice.
All right.
Well, I'd like to talk about Jupyter.
So Jupyter Notebooks.
Oh, yeah.
So this is.
How do you use it?
So like, I was just fascinated by the clickbaitiness of this, but it's okay.
Eight surprising ways to, eight surprising ways how to use Jupyter Notebooks.
And I got to say, I didn't know you could do some of this stuff with Jupyter.
So it's pretty cool.
So the first one, package development.
Why would you?
I don't know why.
But, you know, some people that are more comfortable in Jupyter than they are in IDE or something.
Maybe it's good.
So there's a package called MB Dev that you can use to, and it's by a company called Fast
AI that you can use to help with package development, including, you know, trying to get your CI working
and your tests all in one place and demos and documentation and stuff.
So that's kind of neat.
Like that idea.
Oh, I definitely should try to play with that to see how that works.
Apparently there's a video.
Somebody gave a talk around it, I guess, maybe.
Lovely.
Yeah.
Build a web app.
So building a web app with Jupyter.
I think that's actually a pretty cool idea.
There's several suggestions using Voila.
I think we covered that.
I think, yeah, we've covered that before.
But the other one, I don't think we have.
PyPy widgets.
I'm not sure what that one is.
So I haven't looked at the widgets thing.
But, you know, more widgets within your window.
Sure.
Why not?
Why are there no?
It's a widgets thing.
You'd think there'd be images on the readme.
Anyway.
And then a framework called Mercury.
And this shows up several times in this.
So Mercury does a lot of stuff around Jupyter Notebooks and doing extra things.
So this shows up several times in this list.
So for one, for creating a web app, which is kind of neat,
especially if you're sharing data and have interactive stuff,
you might have doing stuff with a web application.
That would be cool.
Slide deck.
Got to love it.
I definitely want to try this out because using NB Convert or Mercury,
apparently Mercury does that too, uses Reveal.js.
I think a lot of people have tried Reveal.js before for slides.
But building it within notebooks, building your slide decks within notebooks,
and then having that just run, that's cool.
Building a book.
This is something else that sounds pretty interesting.
I'd like to try doing some code, a notebook, a book-like thing.
Now, I don't have, I'm curious about this.
So the book, you build a website that looks like a book, but that's not a book.
So it says it can be exported to a PDF file, but I don't see anywhere you're exporting to an EPUB or MOBI.
So, you know, I call BS on whether that this is a book.
This is a website that holds book contents as far as I can tell.
Still cool, though.
Running a blog.
This is something I had no idea Nicola could do.
So Nicola?
Nicola?
I don't know how to pronounce that.
I've ran across it before.
I'm not sure what we've covered it, but it's a static site generator.
And it apparently can take notebooks files and just run notebooks as a blog.
So that's pretty cool.
Notebooks as a blog.
Oh, that's interesting.
Well, yeah.
Especially if you're going to write about like some Python technique or something, you just do a little demo of it.
And then publish that as a text thing, or I don't know if it outputs.
I didn't read it close enough.
Outputs the exports every notebook to an HTML file and then publish all the files on a static website.
That's pretty neat.
Doing reports and dashboards, that's kind of like Jupyter would rock at that.
And I think we've covered stuff like this before.
But one of the things in the dashboard section that I thought was neat was this Mercury tool has a schedule option.
So once you set up the report, you can schedule it to execute, you know, like once a day or every hour or something like that.
And that's pretty neat to not have it do constantly, but update your dashboard at a time.
I do like that.
That's really cool.
So you could have some kind of dashboard instead of creating it in the full web app.
You just publish this.
But obviously you want it to refresh, right?
Yeah.
Yep.
So anyway, that.
Oh, last one.
REST API.
This is interesting.
I wouldn't have thought to build a REST API with Jupyter.
So I guess you can do all this stuff.
Whether or not you should, I guess it's up to you.
But anyway.
Yeah, for sure.
Anthony on the audience says, Nicola works well as a static blog generator, preferred over Pelican.
Well, that's saying something.
Nice.
That is.
Yeah.
Brian, wouldn't it be good to know which ones are like more popular, which ones maybe you should depend upon?
Yeah.
All right.
Well, Al.
I took it over.
Let's.
That's all right.
So this one is from, let me get it right here.
This one is from Tankala Ashok.
And they built this one, this thing called pip Trends.
It's modeled a little bit after NPM Trends.
And it just lets you compare the popularity of packages based on their GitHub statistics.
So GitHub statistics, you know, that's one metric of popularity, but let's give it a bit of a run.
So what about if we type Flask says, it immediately pulls up a nice little autocomplete that says Flask, a simple web framework for building complex web applications.
But then all the other ones like Flask to Postman and so on.
It's kind of interesting.
I didn't really, didn't really know about Flask to Postman.
Maybe that we'll talk about that next time, but let's pick Flask.
And then immediately, immediately says, well, what else might you consider along with this?
Like, well, how about FastAPI and Django?
And what do we have?
It also suggested Bottle for a little while.
So we'll throw Bottle in there maybe.
And let's do a search.
And it comes up with a graph that honestly surprised me a fair amount.
There's different levels of popularity, but that's not the first thing that surprised me.
The first thing that surprised me is the regular cycles that all of these packages seem to go through.
Does that seem strange to you?
Well, I've noticed it before and I don't really know what's going on.
Is it the weekends?
Yes.
Very good.
So four or five was the weekend.
Six, four, six, five.
And that's where the dip is.
So people download stuff less on the weekends because there's less.
Create me a new environment.
Create me a new project.
Check it out.
Set it up.
All that kind of stuff, which is healthy, but there's still a decent number of downloads going on the weekend there.
Yeah, I kind of wish that I'd like to see a seven-day moving window, moving average for PyPI.
Yeah, yeah, like a different window averaging or projecting function.
Anyway, what we get here is we see that Flask, sorry, FastAPI and Django are super similar,
like almost tied according to GitHub statistics.
And these are downloads.
I don't think you get downloads from GitHub.
I think this is probably from PyPI or BigQuery or something.
I'm not sure where those numbers are coming from.
Because I don't know where those are on these like time series download numbers are on GitHub.
So they're probably coming from somewhere else.
But yeah, you can throw different projects in here and say, oh, this one's relatively popular compared to that or whatever.
What do you think?
I think it's kind of neat, especially with comparing.
I mean, I've used to, there's other ways to get the stats, but having, being able to grab a few related ones,
having suggestions is kind of neat too.
Yeah.
So it looks.
It also has some more information about the package.
Like if you go to Flask, it's 12 years old.
It has 45 versions.
Its last release was one month ago.
Its dev status is stable.
It requires Python 3.7.
Gives the license and who it's intended for.
And you can see similarly for FastAPI, for Django and Bottle and so on.
Oh, cool.
Also down here in the GitHub stats, you can see like Flask, there's 59,000 stars.
For Django, there's 64,000 stars.
Number of open PRs.
Wow, FastAPI has a lot of open PRs and issues.
That's crazy.
When it was last updated and so on.
So yeah, and it also gives you more comparisons down here.
Like, well, that was fun.
What about Flask versus Django versus FastAPI, which is what we did.
Or NumPy versus Pandas, for example.
You can see them and so on.
That's pretty neat.
I like it.
Yeah.
So piptrends.com, you can check it out.
So I want to talk about, what do I want to talk about?
Class, being classy.
Actually, being callable.
So Trey Hunter put this blog post out called, is it a class or a function?
It's a callable.
And this is actually something that I guess I realized I just sort of got used to with Python.
It's a lot more, if you call something.
Like, as if you would call a function, it might not be a function.
It might be a class.
It might be an object that's callable.
It might be a class object.
All sorts of stuff you could do.
Like, just to be clear, we were talking about, or he talks about classes are callables.
So in like JavaScript or C++, you'd have to say new something.
So you'd have to say like a new date object or something.
But in Python, you just call date time with some parameters and you get back a date time object.
That's neat.
But so it's just, I guess, this is a good article to go through just to realize that you don't really have to care.
There's a whole bunch of stuff that act like functions.
And it's okay if they're not functions.
You just have to know if it's callable.
And he talks a little bit about using a knit, a dunder a knit, to make something callable.
That works.
Properties are like decorators or a thing that are a callable item.
There's some, it's just a good discussion about all of this.
I thought this was a fascinating article.
And I'm not sure I ever really thought about partials before.
Like a partial function is a, is a, like a function that creates a, almost creates an object.
And then you call it with some more stuff and then it creates a, the rest of it or creates an, anyway.
Maybe I got that wrong.
Yeah.
From functools.
I'd never used partial before.
Okay.
Yeah.
And then there's a, there's a call decorator or a call dunder method that you can use that
is helps out with making partials.
And, and talks about iterators and decorators and all sorts of stuff like that, that actually
act like callables, but they're not, they're like objects.
The thing that I don't know where this is, but the thing, there's a, a statement in here
that I thought was amazing.
So there's a, there's a page on the PyPI documentation of the built-in functions within Python.
And, and Trey points out that of the 69, there's 69 listed built-in functions within Python.
Only 42 are actually implemented as functions.
26 of them are, 26 are classes.
And, and one is a instance of a callable class.
So like, and some of them have in Python two, there were more.
And some of the, some of them got converted like a map and filter and range and zip used
to be functions.
And now they're objects or classes or something.
The len function, they use that all the time, right?
It's not a function.
Right.
It's a callable class.
Okay.
And zip, the like reversed enumerate range filter use those all the time.
They're not functions, but they're callable.
So anyway, I just thought that was an interesting take on Python is different than other languages.
It's different.
Yeah.
A lot of, a lot of languages you would never have that ambiguity, right?
But it's the kind of ambiguity that you don't need to know or be aware of.
So yeah.
So maybe ignore this article, but no, no, no.
I mean, it's interesting to know.
I'm just saying like, it's, it's not necessarily a problem that it's not super clear whether it's
a class or function because you call it and it does the thing you want it to do.
So you're good to go.
Yeah.
Like Sam, Sam Morley pointed out here.
Partial is useful.
I think, I think it can be pickled unlike typical closures that can't might be wrong.
But it just made me think about we, in other languages, they really do talk about closures
a lot and things like that.
And we just don't have to care.
It just works.
I don't know.
It just works.
Yep.
Very nice.
Well, we're at the.
Brian, we, yeah, we flew through those.
We did fly through them.
So, and we forgot to plug our stuff.
So we did.
Instead of a sponsor today, we've got work sponsored by us.
So I want to make sure that everybody that is thinking about trying to learn something new
in Python first, check out Talk Python Training because Michael has a whole bunch of awesome
courses and, and you can, I'm sure you can learn something for just a few bucks.
So good prices.
And a new book version two edition two.
Yeah.
I've had a lot of good, a lot of good feedback.
I love, one of the things I love is getting pictures.
I don't know why, but having somebody take a picture either of themselves holding the Python
testing with pytest second edition.
Heck, you can do the first edition too, if that's what you got, but either holding it somewhere
unique, like out in a park or at, you know, near a monument or something.
That would be so cool.
I love it when people send me pictures.
So yeah, that's awesome.
Got any extras?
I have some extras.
Yes.
You know that I do.
All right.
So this first one here, let's, let's check this out.
So this is interesting.
This comes by way of Dan Bader and it's the Orion browser.
Just when you thought there was no more room for new browsers, here's the new browser.
This one is different.
So you can see I'm running Vivaldi these days.
I love that.
Other people are using Brave, right?
And so all of those browsers take the Chromium engine, strip off the Google stuff, and then
put their own shell, many times more private privacy protecting and so on around them.
Right.
And we've got Firefox, which is awesome.
It's got its own engine.
It doesn't do that.
But almost every other browser is let's take Chrome and Chromium and wrap it up in our own
flavor of our thing with our own philosophy on how the web should be.
So this Orion browser is that, but for Safari.
Interesting.
So if you're into Safari, you know, it has things like on your Mac, it has better battery
life and so on.
But think of it as like, I think Brave is probably the closest analogy.
It's like Brave for Safari without the crypto, but it's, you know, got built in ad blocking.
It's got built in tracker blocking and all that.
One of the big drawbacks of Safari is you don't get access to the Firefox or the Chrome extensions,
right?
You just get the Safari ones.
But this one has compatibility both for Firefox and Chrome extensions.
Wow.
In there.
So you could, isn't that cool?
So you can run this privacy protecting anti-tracker Safari with Chrome extensions.
So it's just out in beta, I believe.
It's not, yeah, it's out in beta right now.
So I'm not sure where it is or where it's going to go, but it's a pretty interesting take,
isn't it?
Yeah.
It's certified snappy.
Certified snappy.
I like it.
And it's, I really like its privacy aspect.
So I think the privacy space, and you brought this up, the privacy space is, there's convenience
and there's speed, but I think that's a place where people can, we can open up the browser
wars again.
Yes.
Because in a good way to try to limit some of the privacy concerns or minimize them.
Yeah.
Nobody at Mozilla asked me, but I'll give it, you know, Firefox is having trouble sort
of keeping its market share.
I think if it could triple down as the browser that you cannot be tracked with the browser
that will absolutely preserve your privacy and then add services around that.
I think that would be great.
The big challenges.
Well, I guess, you know, they're 99, 90% funded by Google, an ad company who doesn't want
that.
So there's this, this interesting tension, but I think, you know, that's a path that I think
Firefox should be taking as well.
But I guess I forgot about that, that Google was so, such a big stake in Firefox.
Right.
I think that limits their, their playbook.
I think they can't do things like we're going to make it.
So we're invisible.
If you use Firefox basically, because their biggest supporter would not totally love that,
would they?
So anyway, this is a zero telemetry browser and whatnot.
And you can go and download it.
Apparently it works on Apple Silicon and Intel, but obviously being a Safari wrapper, I believe
it only works on, I think, Mac and iOS things, iOS, iPad and macOS.
But if you're on those, it's a pretty interesting take.
And just from the browser wars in general, I think it's pretty interesting to track.
Yeah, definitely.
It's cool.
All right.
One more quick extra and then off to you.
So last year we all did the PSF plus JetBrains developer survey, which is supported by and
analyzed by JetBrains, but is really a PSF survey.
And we had 23,000 Python developers and enthusiasts participate.
Well, the results are out.
So people can go check those out.
Now I've got a whole lot more analysis that I'd like to do before I talk about it, but they're,
they're already out.
So people can start looking around there and I'll give you more details next week.
Yeah.
Cool.
Yeah.
We should definitely cover it next week.
That'd be fun.
Absolutely.
All right.
How about you?
I've got a small thing.
I'm not sure.
sure.
It really needed an entire section, but Ned Batchelder did what's in which Python.
So it's a page that has basically everything from, what did he have?
From 2.1 to 3.11.
3.11.
Not like everything that's in every version, but some of the big hitters that you might know.
So like 3.10 has union types and structural pattern matching.
And what do you get with 3.11?
Well, we know it's faster, but do we get like how much?
And it's 10 to 60% faster than 3.10.
That's amazing.
And then exactly.
That's really amazing that after 30 years, they're like, oh, you know, this year we're going to make it 50% faster.
Like that's, that's incredible.
I'm glad that's happening.
Yeah.
And then a new module Toml lib is coming.
So like, which is interesting that we've got pyproject.toml and it's, it wasn't part of the standard library yet.
So, but a whole bunch of things, like if you can't remember, like if for some reason you forgot f-strings came in and what was it?
3.6.
Apparently I forgot.
So they came in in 3.6 because it's on the list unless, unless Ned got it wrong, which probably didn't.
So now I think 3.6, I think that's the biggest mover for 3.6 there.
Yeah.
Yep.
And data classes in 3.7.
Yeah.
So lots of cool stuff.
Fantastic.
Marie Schreiner out of the audience says it's the top features from each of the versions since 3.0.
So not everything, not extensive, but like sort of the big hitters.
Yeah.
I wasn't going to say top because, you know, there's a lot of people that worked on a whole bunch of other stuff that are on the list and I appreciate them as well.
Yeah, absolutely.
And some of it's just setting the groundwork for the next amazing thing.
Yeah.
Well, let's, let's wrap up the show with something funny.
All right.
Ready for a joke.
All right.
This is a joke by Jen Gentleman, but called to our attention by Luke Morley.
And it says, Jen says, a programmer had a problem.
He thought, I know, I'll solve it with async.
Has problems now, period, too.
He.
Because of race conditions, of course.
Yeah.
I like it.
I like it, too.
Quick and simple, but yeah.
There's a lot of variations on that joke and they're all good.
Yeah.
Most of them are good, I guess.
Anyway.
Well, thanks again, Michael, for joining me today.
And it's a great episode.
Yeah.