Hello and welcome to Python Bytes, where we deliver news and headlines directly to your earbuds.
This is episode 239, recorded June 23rd.
It's almost the end of June. Wow.
2021. I am Brian Okken.
I'm Michael Kennedy.
And I am Nick Moore.
Welcome, Nick. Thanks for joining the show.
Before we jump in, tell me a little bit about yourself.
Yeah, sure. So as I said, Nick Moore.
I'm based out of Ohio and I work as a data engineer, Trimble Transportation.
It's a software company aiming to like revolutionize the way we supply the world and like simplify and connect like the world supply chain.
Like it tries to make it easier to move goods and freight all around the world.
I'm also the co-organizer of ClePy, which is Cleveland's Python meetup group.
Thank you, Michael, for sharing it up on the screen.
So, yeah, that's a bit about me.
Nice. I enjoyed Cleveland when we were there for PyCon.
Yeah, I think I met you guys there.
Cool.
I think you guys were in the JetBrains.
That's right. We were.
It was really great to be in Cleveland for a couple of years.
And I guess we just completely missed Pittsburgh.
But they're going to get another round out of here as a redo, which is cool from COVID.
I got a chance to speak at the Cleveland Python meetup and talked about memory.
Was that right?
Yeah.
You talked about how Python manages memory.
It was like a really cool deep dive into that.
Yeah.
Thanks.
That was super fun for having me.
Now it's good to have you on our show.
Yeah.
So was that on purpose?
Did you make a joke that you couldn't remember what the talk was about?
No.
I know how my brain might store the memory of what I spoke about, but I just, it could have been that or async and I wasn't 100% sure which one it was.
We did talk about async too, though.
Cool.
Yeah.
For sure.
Speaking of async, Brian, you see what databases tells us about it.
Well, this is object relational mappers also.
So we have ORMAR, which is an async mini ORM for Python, which supports Postgres, MySQL, and SQLite.
This was a suggestion sent to us by John Hagen.
So thanks, John, for sending this in.
And I actually haven't played with this a lot.
I was looking around.
It looks pretty neat.
But I'm going to quote John here.
He says, it's a really cool ORM that combines Pydantic models and SQL models into a single definition.
What is great about this is it can be used to reduce the repetitive duplication between the models for an ORM and the Pydantic models for that FastAPI needs to describe serialization.
So I guess you do have to specify that twice normally.
Yeah.
Normally what you do is you would have the data model, the classes that do the exchange on the API level.
So those would probably be Pydantic.
But maybe then you have something like a SQLAlchemy model.
And then somewhere in the middle, you've got to copy the SQLAlchemy data over to the Pydantic model, send out over FastAPI and you get it back.
Then you've got to copy that from FastAPI and Pydantic back into SQLAlchemy.
Because SQLAlchemy types are not really meant to be transferred on the wire.
You don't get the open API documentation that you get from Pydantic integration and all those sorts of things.
So that's normally what happens.
But if your database model can also be a Pydantic model, then you don't do that back and forth.
Yeah.
And anytime you've got duplication, it's like that dry issue of just you're going to mess it up sometime.
It's going to be wrong.
And I think that's why SQLAlchemy, I think in version 1.4, they've been playing around with a lot of ideas on how to integrate data, not Pydantic, but data classes and the ORM style base models.
Four different propositions of how that should be done, but it's not yet perfect.
So I think that's something that it looks like they could learn from Omar here.
Or at least it's good to have these sort of experiments going on for everybody to look around and see how do we move forward so that we can do this cleanly.
Yeah.
The one thing I will say is that with all of these ORMs, I don't know why they never give some love to SQL Server.
I always see Postgres, MySQL, and SQLite.
But like SQL Server is pretty cool too.
Where is the support for that?
What's SQL Server?
So that's like Microsoft's, you know what?
I think it really matters what audience you're addressing, Nick, right?
So if you're talking startups and a lot of the open source crowd, yeah, it's all Postgres.
Or, you know, if you're talking to Michael, it's all MongoDB, right?
But if you're talking to enterprises, boy, oh, boy, do a big bunch of those enterprises run on the Microsoft stack.
Yeah.
Windows, Windows Servers, Microsoft SQL Server.
And that's a non-trivial amount of the use cases for these things.
So I agree that it should get some attention, even if it's not necessarily the one that the maintainers or many of the people are most keen to use.
Yeah, and I agree.
It was a joke, but one of the things I wanted to point out that John mentioned is that one of the benefits of Ormar is there's a quick start specifically for FastAPI.
So you can look at the documentation and there's a FastAPI quick start on how to get this running with FastAPI.
What an interesting combination of descriptors from the ORM class side and Pydantic models you get here.
So for this, we have like the Pydantic model-based type of thing.
We've got the columns specified with type information that Pydantic would use, but then you set them to things like an integer column that's a primary key or a string that has a max length setting and things like that.
Yeah, it's like the worst of every world.
But it's better than repeating stuff, right?
So, yeah, interesting.
Yeah, I think it's pretty good.
And Nick, you mentioned SQL, Alchemy, and Data Classes.
Pydantic also has some integration for working with Data Classes as well.
So maybe there's a way to bridge those things across for like FastAPI and similar situations as well.
I haven't tried that, but it's possible.
Yeah, let's see.
Out there in the live stream, we've got Sam Morley.
Hey, Sam.
Says, this looks a lot like a Django ORM.
Yeah, absolutely.
It really does.
And then Dean is hoping that we'll get some support for a very important database, AccessDB.
That and, oh gosh, what was it?
DB2 and a couple of the others.
Yeah, there's some really important ones that we might be forgetting, but I think it's going to be okay.
Oh man, Access, that gives me PTSD from college.
I can imagine.
All right.
Well, speaking of people who might be getting some trauma, let's talk about NoModuleNamed.com.
In fact, it's now its own website.
You used to think of it as like an error, and now it's actually a service.
So error explanations of a service, I guess, is what you would call it.
All right.
So Garrett Dune pointed out that there's this website called NoModuleNamed.
And it looks super plain.
And I went to it like, what is this?
It has 3,626 packages.
And, oh my goodness, like 2 million modules or something like that.
And it has 151,000 package install guidelines.
So for example, what if I'm working with HTTPX?
And I get the message that says, Python error, no module named HTTPX.
Right?
This is what you would have if you wrote import HTTPX and you went and tried to run it,
but you were new and you didn't realize there were external dependencies or that HTTPX wasn't
built into the standard library, you would get that error, right?
Yeah.
So this tells you how to fix it.
It says, oh, this is probably because you don't have the package HTTPX.
Let's see if I can go something like FastAPI.responses.
Is that a thing?
And what will it tell me if I try, oh, no such module.
Yeah.
But so NumPy, for example, it'll give you a lot of these and it'll tell you, this is
probably because you don't have the package NumPy or NumPy MIPS64 installed.
So that's what I was looking for is if it would sort of show like, well, the package name is
not exactly what you're looking for.
So maybe BS4, right?
Sometimes there's these modules that, yeah.
So for example, if I say BS4, it'll say, oh, it's because you don't have, if you have
the error, no module name BS4, it's because you don't have beautiful Super 4 installed,
right?
So it's more than just like, duh, pip install the thing that there's no module of.
It tries to help a little bit more with understanding that and it tells you how to get the latest
version.
It tells you how to install it.
So yeah.
And there's even a related article.
Extremely beautiful like SEO on that with people just Googling error messages as well.
Yeah.
So pretty, pretty interesting.
Garrett Dunn, thank you so much for sending that in.
It's simple, but you know, these kinds of things can help people who are new and are getting
in.
And I think one of the powers of Python is we have people coming from all these different
backgrounds and experiences, and they are not all computer science people that know about
package managers and like love that.
They're just like, oh, I know that I can do cool.
I can like load this file and make a picture out of it that I need to work on.
But I get this stupid no module named this.
What is this?
Right.
And then they can, you know, these kinds of things can help.
Yeah.
Well, I'm trying to teach my 11 year old some programming and we started with packaging.
Yeah.
We didn't.
I know you started with virtual environments and then packaging.
Yeah.
Brian, I thought you would have started with testing first.
Yeah.
I always test first.
Yeah.
I think this is like a really, this is like a really cool project.
I find it's like a really cool thing.
I find it super useful when I'm working on projects related to GUIs like Qt or Phoenix.
No, no.
WX Python.
Because like those packages come with so many underlying dependencies.
And sometimes you might miss one or might miss something that like is an OS dependency that you don't know.
I feel like this could help you out.
And I've run through this a few times where like I'm using like a package that is built on top of Qt.
But then it tells me you don't have PyQt GT.
PyQt 5.
Right.
Exactly.
Well, I like that.
I think you probably already mentioned this, but the error message is the module not found.
That's often not the same.
It's not the same name as the thing you pip install.
Yeah.
Like one that drives me crazy is DateUtil.
I love DateUtil.
I think it's like magic for the pain of parsing dates.
But that's not what you install.
You install Python underscore DateUtil.
Right.
And so there's just, it's those situations where you're like, why is there no DateUtil?
I pip install DateUtil.
And then it's not even the right thing.
Or, you know, it's just, yeah, I think it's helpful to sort of put those things together for people.
Yeah.
And for people doing new packages, don't do this if you can.
Even if you have the perfect name for your package, maybe come up with something else that you can actually, it's available on PyPI.
Yeah.
Yeah, for sure.
All right.
Nick, you got the next one, right?
Yep.
I got the next one.
So I was looking through Jupyter.
So I'm going to get, as I said, as a data engineer, I often use Jupyter for like data wrangling and just trying out how to like clean up some kind of data before I actually do the actual cleaning in our data pipeline.
And so I stumbled, I got the new iPad.
And I was, I went, I went to like tinkering around with like Python code and I was like researching into how to do that.
And I stumbled across Jupyter light and I was like, okay, cool.
Jupyter light.
But sometimes I'm not going to always going to be connected to internet using my iPad.
And then I looked deeper into it and it's a, Jupyter distribution that runs entirely in the browser.
And it's like built from the ground up using Jupyter lab components and extensions.
And that's cool.
And the, and the kernels that are available are like in the browser.
So like there's a Python kernel that is like in the browser and it's built using PyIodide.
That was like really cool to see.
Um, and there's also like, I think there is a, where is it in the user guide, there are other kernels such as, yeah.
JavaScript and P5 JS, which I think is like a graphics library to build like things on canvas, but it was really cool to see like it's supports Python 3.8.
And, you get like start session.
You can run Python code, Python completion, which is really cool.
It's interesting.
They call the, the kernel Pyolite.
Um, Pyolite based on PyIodide.
Yeah.
And this is, I pulled it on.
This is how it looks like.
And it looks pretty cool.
So it also supports, right.
I think for now it supports Altair and, I think Matplotlib as well.
I think.
Yeah.
Matplotlib.
And so like open up this Altair notebook.
Um, it even has something called Micropip.
which is like, I don't know what this means, but if you're, it, I think it means that it's, like, is a package manager, but for the browser for Python, which is interesting.
Oh, and it's, it's, it's, asynchronous because it's JavaScript basically.
Right.
So it's a wait micro pip installed like Jinja2, or Altair or something like that.
How interesting.
That's very cool.
I think it also, everything that you download
and everything that, all the data that you, like, load up,
it's being stored in the browsers, like local storage
or some other, I don't know, indexed DB.
So it's, like, self-contained.
The only thing I noticed is that right now,
it's not, what was the word here?
A PWA.
Yes, I was just thinking it would be fantastic
if that was a progressive web app
and then you could just have it in mostly offline mode, yeah.
Edge does a great job with PWAs
and every time it detects, like, a manifest adjacent
to show you, do you want to install this app?
And I would just love to have, like, just click install
and then have Jupyter Lite wherever I go
or load it up on my iPad and then disconnect
and still be tinkering around with what I want.
So this is all browser-based.
So that's really cool.
I'm not going to run any of these,
but I encourage everybody to check this out.
It's pretty cool.
Yeah, yeah, this is really cool.
I do the same thing with, I use Brave.
So I have, like, a YouTube app installed on my Mac
and I've got a Twitter app installed.
All is progressive web apps, so you can just launch them.
I do wish Firefox supported that.
Firefox, people, if you're listening,
bring back the progressive web app.
We all need this.
Yep.
Yeah, that's cool.
What are some of the other notebooks in there that look cool?
Are these, like, demo ones or did you create these?
Yeah, there's a demo one.
So there's a P5JS one.
There's the Altair one.
I don't know what Folium is.
There's the interactive widgets, which is cool.
So it still uses Jupyter's iPython notebook widgets,
Matplotlib.
Oh, Plotly as well.
Nice.
And Plotly, cool.
And so this is a de facto, like, Pyolite one.
So it supports Matplot, Pandas.
That's cool.
It supports LaTeX as well.
Yeah, it's great.
And so, like, as I was saying before, Pyolite is, what is it?
It's, like, implementation of Python on the browser.
Actually, implementation of Python is on the computing stack on the browser.
So I think things like Pandas, NoobPy, SciPy, SciCutLearn are already, like, available.
It's within the Pyolite ecosystem.
So you don't have to...
Yeah, I had the guys behind it, you know, Firefox and Mozilla were behind it originally, at least.
And I had them on Talk Python.
I believe it's WebAssembly based.
I think what they did is they took all these major visualization libraries and things like Pandas and NumPy
and compiled them all into a Python plus those WebAssembly thing that runs in the browser.
instead of a JavaScript version, which is pretty awesome.
Oh, even Symbol.
Yeah, the symbolic output, like, got the math symbol integral of the square root of one over XDX.
Beautiful.
I wonder if you could get hand calcs on it.
Oh, yeah.
Awesome.
Cool.
All right.
Well, that's a really good one.
I love it.
All the data scientists out there can definitely enjoy that.
Yeah, cool.
What do we got next?
I think you're up next.
Oh, right.
Okay.
So next, we've got...
More plotting, maybe?
Yeah, more plotting.
So this is a long title.
Basically, it's lots of plots.
There's eight popular graphs made with Pandas, Map, Plotlib, Seaborn, and Plotly Express.
And I've seen a lot of articles and stuff talking about how to do different plots in one or more of these.
And a lot of them are...
A lot of the articles, and rightly so, are focused on something cool you can do with one library that you can't do with others.
And I've seen Seaborn ones like that.
And that's great.
What I like about this article is it's like, well, let's just take these different pandas plotting and Map, Plotlib, Seaborn, Plotly Express, and do the same plot.
Let's do something they can all do.
And so that's what this article does.
It does a whole list.
You've got normal line charts, grouped bar charts, stacked bars, pies, a whole bunch of things, and histograms.
And then you can just compare to see what it looks like before you try.
And for one, it's got the output, what do the graphs look like, which is important.
But also, it's a fairly simple article.
It's talking about what the plots look like, but also how do you make them?
It's in a Jupyter Notebook Viewer.
And it shows you what's the code look like to get these plots set up.
And I think that's a big part of choosing your plotting library is looking at the API to see what kind of API looks comfortable to you.
Yeah, I've got to write this code.
Will I be able to remember this?
Yeah.
Or will it be like regular expressions and I learn it every time I use it?
Yeah, or if you get stuck with one and you want to switch to other to sort of look at what the deltas are.
I like these side-by-side apples-to-apples comparison sort of articles.
So I think this is good for choosing the simple parts of plotting.
But some of the comparisons are sort of funny because the bar charts just kind of all look the same.
That one's orange versus orange and blue versus green and blue.
It's not all the same.
Yeah, but you get down into some of the fancy ones and they do look great.
Some of the area charts.
Yeah, that one looks great.
What's that?
Polly Express area charts look awesome.
Yeah, the area charts look good.
And I didn't know what a donut chart was.
A donut chart looks like a pie chart with a hole in it.
Yep.
Why do people use that?
I think it's because of like with the pie charts, the sectors are kind of, it's kind of, sometimes it can be hard to see like how much width.
No, like, yeah, the circumference of like this sector.
So maybe the donut chart kind of makes it easier to see like, okay, this takes like all of this.
It's just a visual thing, to be honest.
Yeah.
Okay, good.
Nick, this is your world.
What do you think?
I think this is really cool, but to be honest, all of these APIs don't compare to the grammar of graphics from R.
And so I usually, if I am going to do graphics in Python, I would prefer to use something that like conforms to the grammar of graphics.
Because to me, that's kind of, you know how like Python has the import this and it's all philosophy of how to write Python.
The grammar of graphics like has that.
So it has like, gives you these like sentences, so to speak, to build graphics.
And I was like, that makes so much sense in my head.
So like for graph, for graphing lab reads, it's either Altair or ggplot.
And there is like a Python port of ggplot that's pretty good.
But I think Altair is like the Pythonic de facto version that I've used.
That's really nice.
All the other ones that make me have to do like, like, like, like, do these method calls on objects.
Just, I can't, I can't remember it.
I have to come back to something like this.
So how do you use gnm.lib?
Are you using Seaborn?
I really like the fact that like Seaborn has a lot of one liners to like do simple charts in one line, which is great.
Like with the grammar graphics, right?
It still makes you have to build everything out.
But if I'm building something really custom or I am just building something that I have, I want to have complete control over.
The grammar graphics just gives me a better way of like remembering what to do compared to having to remember all this API, all this API, all this method API calls.
Well, I mean, the author, Dylan Castillo, says, let me know what you think.
So maybe we can give him some feedback to add Altair and a couple others.
Oh, yeah, that'd be cool.
Dean also has some thoughts out there, right?
Oh, Seaborn and Pandas use Matplotlib in the backend.
So you can do everything they can do with Matplotlib.
Okay, maybe harder, but not impossible.
And also, that's probably why they look all the same.
They are the same.
Turtles all the way down.
And he also says, remember, kids, almost every command in Matplotlib returns the object it charts.
That's the start of OOP, object-oriented plotting.
All right, right on.
Oop, it'd be two Ps.
Oop, oop, oop.
I don't know how to pronounce that.
All right, well, Brian, you got to talk about databases.
So I'm going to talk about databases, too.
But my databases are going to be smaller and in-memory and embedded, but also about MongoDB.
So there's this really cool one created by David Latwi called MontyDB.
So it's a Monty.
It's a MongoDB tiny-ified.
So it's MongoDB implemented in Python.
And you can have it in process, kind of like SQLite, I believe.
We've covered a couple of these libraries that are starting to show up that let you do sort of embedded MongoDB, which I think is really neat.
So it's inspired by TinyDB and its extension TinyMongo.
So the way you work with it, it's super simple.
You just import the Monty client.
And if you want to go crazy, you could say as Mongo client and make it basically the same.
And then you can give it connection strings like colon memory colon.
That should look familiar from something like SQLite.
And then you can insert data to it, do all sorts of things, and do queries against it, run the MongoDB query syntax against it, and you get the responses back, which I think is pretty cool.
It's certainly interesting for testing.
If you told it to use a file storage, it could be an interesting little embedded database and things like that.
So pretty cool.
It supports many of the MongoDB versions up to 4.2 and 4.4 on the way with wave emoji.
I'm not really sure about that, but also supports the...
What's that?
I think it's sweat.
Oh, gotcha.
Like the work is being done.
Gotcha.
So you can pip install MontyDB, and it will work in sort of its way.
If you want to use the actual serialization library from MongoDB itself, you can say install MontyDB bracket BSON to install that as well.
And it also has a lightning memory map DB, LMDB library.
You can use that as the storage engine as well.
So you can pip install, you know, add that on as well.
So for the storage, you've got in memory, you've got a flat file.
It'll actually use SQLite as a back-end store, which is pretty cool.
And then that LMDB lightning memory mapped DB.
So this looks pretty neat to me if you're going to do some kind of embedded thing or you're going to do some testing and you want something lightweight that's not a separate server you've got to set up and run and all those kinds of things.
This is cool.
I think it's awesome.
Could you make this a pytest fixture, Brian, that just gives you, like, presets up your database and gives you access to the connection or something?
Yeah.
I mean, actually, I'm not really a fan of people switching their databases too much for testing because most modern databases have in-memory options or smaller version options.
But, I mean, we use SQLite for tons of stuff that's not just for testing.
And if you've got SQLite at the back-end, there's no reason why this couldn't be a production thing then.
Yeah, absolutely.
No, this is really cool.
This could be really useful for, like, CLI apps that need to store your things.
Yes, exactly.
You want to have a little thing, but you don't want to say, oh, you want to run my little utility I packaged up with Py2 app or Py2.exe or something?
Yeah.
You're going to need to install MongoDB and become an admin of that.
No, you just use, like, a SQLite file as the back-end store or the LMDB version.
Another thing that's common from the MongoDB world is there's a set of CLI tools that allows you to manage it.
So I can connect to it.
I can import a bunch of exported files from some other or backed-up files from some other MongoDB instance and import that into my current server or whatever or create those exports, right?
There's actually a bunch of utilities called Monty Import, Monty Export, Monty Restore, Monty Dump.
All of these are the parallels of Mongo, Mongo Dump, Mongo Restore, and so on, right?
So if you were used to working with MongoDB, it's not just explicitly that there's some API to talk to some file.
There's also, like, the tools that are there as well.
Yeah.
Yeah, I don't know.
I think that could be a cool project.
So why don't I make this mostly for just fun and practicing on it, but also need it to run in this limited little environments for, like, render farms in the film industry.
So that's pretty cool.
It's a side project also with render farms.
It's a side project for my supercomputer, yes.
I love the name, by the way, Monty, Monty Python.
I love it.
Yeah, I mean, yeah, it really brings the MongoDB wordplay in with Monty Python, Python origin.
Yeah, pretty cool.
All right, Nick, you got the last one.
Awesome.
Exhaustiveness checking with mypy.
So essentially what exhaustiveness checking is, is a feature of, like, a lot of type checkers where they guarantee that the programmer has covered all their cases.
And so with mypy, you could essentially check things, like, whether you've covered all the, like, you have written all the if statements you're supposed to write at compile time rather than figuring that out at runtime.
And, like, I really got into using mypy and trying to, like, have it save my bot a lot in the way I think about code by embracing types.
So I stumbled across this, which was, like, really interesting, where this article written by Haki Benita went into how, like, exhaustive net checking actually works.
So they start out with an enum that has order status.
And you have a function that is called handle order that takes a status, which is an instance, which should be an instance of order status.
And so in his function, he has this, like, if status is order ready, you do something.
If status is order shipped, you do something.
But then he gave this, like, added this, like, new, like, scenario where what if you wanted to check the status of something scheduled?
And so he tried to run mypy right now.
I didn't complain about it.
So it was like, okay, cool.
Yeah.
Because one of the things that's very common is if you have something like a set of cases, in this case, it's put together in an enumeration.
Yeah.
You have more cases over time.
But all these if, else if, else if, else if statements all over your code, have you exhaustively gone through and added that case check for all of them?
Probably not.
Yeah, probably not.
Unless you've got good tests.
A really good test.
Yeah.
Okay.
And so he proposed, like, one quick way of checking that you handled all cases is by adding this assert false, comma, unhandled status.
And you pass in the status using f-strings.
And so then when you try to pass a state that you have not actually handled before, you actually get assertion error, right?
Which is all right, but if you use mypy, there's this clever trick where you create a function called assert never that takes a value called no return and returns no return.
And in it, it has the assert false unhandled value.
And so then when you use that function in your handle order function, at the end case, you have this else assert never and you pass in the status.
Now when you check with mypy, mypy will know, hey, argument one to assert never has incompatible type, literal, order status schedule, expected, no return.
Oh, how interesting.
Yeah.
And this is a compile time and you can actually get this.
Yeah, yeah.
That's, I think that's the important thing because I was looking at that going, oh, I could just add the else statement and put the assert there and have nothing to do with mypy and it would catch that error.
But that catches that error when that code runs.
Like I said before, you know, hopefully there's tests, but oftentimes there's not tests for everything.
Yeah.
And so especially there might not be a test for the new thing you've added.
And so this is cool in that it checks all the possible types that could go in there.
That's cool.
Yeah.
And the part that really got me was that it integrates with your IDE.
So PyCharm, VS Code, or any editor that implements a language server can then like look at this and say, hey, you haven't handled all your cases.
Right.
And you get that immediate feedback rather than having to run your code and then find out, oh, dang it, I missed this case.
Right.
Yeah.
So people who are not looking at the live stream YouTube stream, which is almost all the people listening.
Nick is showing on the screen this assert function that's checking the numeration.
And there's just a red squiggly line that literally says assert never has incompatible order status that's scheduled.
That's the missed enumeration case.
I think that's incredible that actually finds this.
Yeah.
And it works because mypy uses this technique called type narrowing.
And essentially what that means is that it would, given a variable as it goes through like a control flow, like if statements, switch statements, my loop, mypy will like kind of confine or in other words, narrow down the types as it goes through those control flow.
And so it works with enumeration types, unions, literals.
So I have in the article, there are examples of how you could pass in a union of different types, strings, float, and you could still use this technique and to tell you, hey, you've missed a case.
Or you could do this with literals.
So you have like RGB and then you only implemented the, you only check for like two cases, which are R and G.
And then to tell you, hey, you did not handle the B case.
So yeah.
And so like the article goes further into different ways in which you could set this up.
Have mypy check all of the different cases for you, which is really cool.
You've even got like the, the, the various sweets for cards, like clubs, diamonds, hearts.
Yeah.
It's interesting that like to mypy, when it sees an enum that has like clubs, diamonds, hearts, and spades, all it sees is like a union of literals, which are sweets, cards, sweet clubs, sweet hearts, which is actually interesting.
That's how mypy sees it.
Yeah.
That's very interesting.
I mean, basically it's emojis.
Yeah.
It's emojis.
Right.
The one other thing I wanted to mention here is that there was a specific, oh yeah.
This feature is actually something that Guido actually thought was pretty cool.
And so I think it's part of a PEP 622, a structural pattern matching already.
So if you are matching against an enum or something that has like multiple different like states, the matching, hopefully Python 310 will give you a nice error saying, hey, you missed a particular case.
And this could really, and if you're a Django developer or you just use Django or even, yeah, you just use any ORM and the ORM provides something like choices where like yes, no, or dollar, euro, like these kinds of choices in the field.
This works pretty well.
And so in your Django code, you could actually have mypy telling you, hey, you missed handling a particular case.
Crazy.
Yeah.
That's awesome.
Yeah.
Which is really cool.
Yeah.
Sam out in the live stream was sort of on to the same thoughts you were talking about with Peter there.
I wonder if one could hack on the match mechanism to deliver this functionality at runtime using by somehow getting all the variants of the enum and checking the branches, the AST or something.
Yeah.
That's interesting because I know that part of the structural pattern matching, like any object can implement the magic method match.
And maybe that's like, yeah.
And maybe that's your gate, like that's your entry point into providing that kind of checking at runtime.
Of course, with Python, anything that is around runtime checking, there's like performance costs with that.
So be careful.
Yeah.
But having this built into mypy already would be good.
And Juergen is talking about it on the live stream.
He says, I wonder whether you could rewrite the code
to not use if statements at all,
but be more polymorphic, which I agree.
It's a really interesting idea
with the method overloading and stuff.
And it reminds me back a couple of weeks ago,
Brian talked about function overloading
with single dispatch and multiple dispatch.
And yeah, you could kind of more or less
make that happen there.
So yeah, pretty neat.
Although you still may miss a case.
I'm not entirely sure.
At least in the enumeration bit, that won't help you, right?
Because the enum will still be the same type.
It'll just have more values.
Yeah.
Awesome.
Good one, Nick.
Brian, what else we got?
Well, I've got a couple of things.
One of the things I wanted to note was that
this is the second week in a row
we've featured an article by Haki
and the third in this year.
So we should probably try to get him on the show or something.
Yeah, absolutely.
That sounds good.
He's doing some good writing.
So thanks.
The other thing I wanted to mention is I've got...
Oh, yeah.
By the way, my book is out.
Yay!
This is the book, too.
Yeah.
Second edition of pytest is available for beta.
So people can tell me everything that's...
I already got it.
Somebody said they have got an issue.
It's a minor issue with it already.
So thanks.
But it's just been me and my editor so far working through it.
So having more people, more eyes before we go to shipping the physical book would be great.
So, of course, this is through Pragmatic.
But if you go to pytestBook.com, it'll take you there.
So that was my extra.
Right on.
Cool.
I've got a couple as well.
Yeah, I got some neat ones here.
So how often do you maybe have like a blueprint floor plan?
Maybe you're looking at a house and you're trying to decide whether you want to buy it.
What would it be like to actually live there?
Maybe you're trying to figure out, well, I'm planning out this apartment or I have this place.
I want to remodel it like IKEA it all out or something along those lines.
I ran across this thing that uses some interesting models called plan to scene.
So the idea is it'll take what is literally a floor plan, like a blueprint floor plan that shows like swinging doors and bits.
And then you tell it what kind of room it is.
It's like a bedroom or a bathroom or whatever.
And it will generate a 3D world that has things like sinks and toilets and couches that are three dimensional, not just somehow projected in there.
So there's all of these interesting things you can see.
If you pull up the site, there's all these like spinning worlds.
And you can see that they've created these little environments just from floor plans, which I think is pretty insane.
So anyway, you can go ahead, Nick.
No, that's really cool.
And I think I wonder if like, because like Trimble, we, we own like SketchUp.
I wonder if they do this kind of stuff.
They take floor plans and then they make it 3D.
That's really cool.
Yeah.
There's a whole bunch of comparisons of how it used to be done, how you can pick like different, you know, different flooring and walls and source codes available on GitHub.
People can run with that.
So that's pretty cool.
It's called Plan to Scene.
And then just a quick shout out to this TCAS podcast I happen to be a guest of recently.
And we got to talk about Python and data science and how Python and data are sort of changing the world and stuff.
And it's really fun.
So people can check that out.
Yeah.
And that's it for the things I got.
Nick, anything else you want to throw out there?
Yeah.
Just a shameless plug.
As I said earlier on the live stream, I co-host the Clipi, which is Cleveland's area Python meetup group.
And so we have meetups every second Monday of the month.
And one of the reasons why I would encourage anybody across the world or U.S. or everywhere to still come and present is because oftentimes meetups are a great place to present talks that you are planning on giving.
And maybe like continental conferences or like other larger conferences, you know, smaller crowd.
And, you know, we show you guys a good time.
Right.
So it's a great place to come, give your talk, get feedback from that, and then, you know, take and improve on it.
So that's one.
And then the other shameless plug is that Pye Ohio has its own conference coming up on July 31st.
Registrations are open.
We have pretty cool T-shirts.
So, yeah, register.
And that's a, is that live or streaming?
Yes, that is being streamed.
Okay.
How about your meetups?
Are those being, are those streamed or live?
Those are virtual.
We used to have them like in person.
And that's, I really, that's when like.
And then it really messed things up because you have stuff like pizza over and those have a good time talking about Python.
But no, the virtual setting has given a lot more people access.
You know, we're able to have more people on.
So.
Nice.
Yeah, that's fantastic.
And Pye Ohio is definitely one of those big regional conferences that a lot of people pay attention to, even if they're not in Ohio.
Definitely.
Are you going to go back to in-person only?
Are you going to do like a hybrid stream and in-person or is it going to be, what's your plans for when the world returns to normal?
That's if it ever returns to normal.
I think we'll change forever.
But to answer your question, I think my co-organizer and I have been thinking about them.
We don't, we're not yet set yet.
Like we see the benefits of the virtual, but we also see the benefits of the live.
And there are things that have changed so much.
We don't even know whether the live person is still available.
But no, it's something we're thinking about.
Yeah.
Cool.
Well, it's a challenge.
I think all the meetups and other events are having, especially these smaller, like monthly, biweekly sort of things.
Yeah.
You know, it's one thing to say that there's going to be a big conference and we'll all go to it or not.
But you're doing it every couple of weeks and it's mostly local, but not 100% local.
Yeah, it's a challenge.
Yeah.
Fantastic.
All right.
Brian, you ready for a joke?
Definitely.
Okay.
So I've got one and then Nick has one.
So this one, the title of the joke is Root Beer Float.
Okay.
So a programmer walks into a bar.
He orders 1.000000119 root beers.
The bartender says, I'm going to have to charge you extra.
That's a root beer float.
The programmer says, well, in that case, make it a double.
It's bad, right?
That's bad.
Yeah.
All right.
And Nick, you've got one as well.
You want to do this one for us?
Yeah.
Would someone like to joke?
You want me to be the bearded person?
Yeah, I really have something going on there anyway.
All right.
So will refactoring the code improve the loading time?
Not really.
Will it improve the security then?
No.
So it's for browser compatibility?
Yeah, no, not really.
Nope.
So tell me, why is it always the same old story with you guys wanting to refactor everything
I need to know?
Because as devs, if we know, excuse me, if we know we've left behind some messy code,
we can't stop thinking about it.
We wake up in the morning at lunchtime in the evening when we go home and when we're trying
to go to sleep.
It haunts us.
You know, it haunts us.
I love it.
And it's true too.
It's totally true.
All right.
I have one more joke for you guys.
Oh yeah.
Hit us.
All right.
How much does a chimney cost?
No idea.
Nothing.
It's on the house.
Very good.
That's, I have a friend that is so, so into dad jokes, which is weird because it's only
22.
Practicing.
Practicing for the future.
Yeah.
I don't think dads can be blamed for all bad jokes.
Anyway.
Yeah.
I want to highlight, Juergen, says that they cost 2,500 euros.
That's expensive.
Well, thanks a lot for joining us today.
Uh, this was a lot of fun and, thanks everybody in the stream for showing up and, we'll talk
to everybody next week.
Thanks.
Bye everyone.