#243 Django unicorns and multi-region PostgreSQL - podcast episode cover

#243 Django unicorns and multi-region PostgreSQL

Jul 21, 202142 minEp. 243
--:--
--:--
Listen in podcast apps:

Episode description

Transcript

Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 243, recorded July 21st, 2021. And I'm Brian Okken. And I'm Michael Kennedy. And I'm Simon Wilson. Welcome, Simon. Thanks for agreeing to show up today. No problem at all. I've been looking forward to this. If anybody doesn't know who you are, can we do a quick, who's Simon? Sure. So yeah, my name's Simon Wilson. I've been doing Python bits and pieces for

around about 20 years now. So I'm a co-creator of the Django web framework from many, many years ago. I think Django has definitely celebrated its 15th birthday now. But more recently, I've been working on a set of open source tools around the site. This project I have called Dataset, which is a web application for exploring a relational database, a SQLite database. But it also has tools for publishing those databases online,

building those databases out of lots of different sources of data. I'm trying to bootstrap an entire ecosystem of data and analytics tooling around SQLite, because it turns out everyone in the world has SQLite, even though they don't necessarily know that they have it. And there's some really cool stuff that you can do with it. Yeah, it's a really cool project.

Yeah, it is. If you wanted to create your own personal search engine, that would let you just go and say, search your Gmail, your Twitter, your Instagram, and your file system all at once. Yep. That's pretty much it, right? That's part of the tooling. Yeah, there's a whole side of it, which I've called dog sheep

ridiculous reasons. But the dog sheep project is about personal analytics, it's about getting your personal tweets and messages and all of the personal data about yourself into one place. So you've got essentially a little mini data warehouse on your laptop that you can use to query aspects of your own life. And that's been a really fun way of driving features in the software, which can then be applied to like company databases and so forth as well. Yeah, super cool.

Well, if I didn't want to do SQLite, I might want to use Mongo. What do you think? You may want to. And so there's some big news around MongoDB. MongoDB 5 is out, which, you know, I'm all about MongoDB, which makes me super excited. Probably won't switch right, right away because I don't actually need the features that are there, but I'm super excited to see things going strong. So some of the things that are relevant, and I think they're really relevant to Python people,

especially the data science side. So basically there's, there's two important things. One has to do with working with time series and the other has to do with stability of the app that you don't want to keep changing so that you can upgrade your database, right? Like if the database API slightly changes, you don't want to have to deal with those incompatibilities until you're ready to take advantage of the benefits of making those changes. So one of the things that comes with is in the

database that are native time series schemas and collection types. That's incredible. Yeah. So you can do really interesting things like a moving average as a query with across like data and stored data in a format that's meant to make that incredibly fast and low latency, but you can also do like, I would like the, the numerical derivative over time as a moving average, as a query or the integral

of this collection has it. So you can do like math as part of your query and get it to calculate those things in really interesting ways. So the time series has things like clustered indexes and window functions and all sorts of interesting things. So that's one. it automatically optimizes your schema for high efficient storage, which is pretty cool. That's think independent of the time series, but not a hundred percent sure. it has the other big thing is the versioned API for future proof apps.

So suppose you build against version, I guess five is the one that has it. Do you build against version five of MongoDB? And then eventually some point like version seven comes along and like, Oh, you can do this new way of querying, but it's going to break some stuff. So you want to use it. You got to fix your app.

You can just say, I want the database to look like version five forever. And no matter what version is in production, it'll, it'll behave the right way according to what you said you wanted it to behave right. So you could say, I want version seven to be like five for me, but it can be version seven

for someone else. That kind of thing. Yeah. The other thing, the way that you talk to it, the way that you interact with it is through just a terminal app you fired up or a command prompt app and you talk to it. And traditionally this thing has been gross. It's been like, it's fine, but it has zero syntax highlighting. It has zero autocomplete those types of things, right? So they're introducing a new shell.

So traditionally you would have typed Mongo, enter connected. Now you type Mongo SH because the old one is still there for compatibility reasons, but that one now has syntax highlighting, better error checking, pretty printing, autocomplete, things like that. So if you're going to do stuff on the shell, then you really should just run the new one. That's pretty cool. I'm going to go with Mongo SH as the,

Oh my gosh. Oh my gosh. What are you doing? Yeah. I'm running the shell, the new one. I know that's pretty awesome. And then also they, they're talking about having serverless, serverless instances. So like Lambda, Lambda type functions where you don't actually have to manage the database or things like that. So I didn't know a whole lot about it. You can also watch the, keynote and actually their whole conference, the keynote is probably most relevant here. It turns out that it's for a

public billion dollar company or whatever they're worth. It's incredibly amateur amateurish and, and like more like a talent fair of like a high school or something like that, but whatever you'll still learn. I mean, it's like, you'll, you'll see it's, it's like super. I have to check it out now. Yeah. It's like worth watching for the, like the, the, the blush worthy, like, Oh, Oh, Oh, come on. Okay. Well, let's just move on now, please. But nonetheless, you do, they do,

uh, demo some interesting things and whatnot. So that's probably enough on that. But if you're into MongoDB, MongoDB five has a lot of cool things to talk about there. You know what else is cool and coming up? Python 311. We don't, we don't even have Python 310 yet. So, well, I do. you, the beta is available for three 10, you can run it, but the alpha is around for three 11, which is a neat. Nice. and, what I wanted to highlight here was, highlight, was enhanced error locations

in tracebacks. I'm so excited about this. This is so cool. So, I mean, Python has not been that bad for tracebacks. I've, I've dealt with worse tracebacks, but the, it points out what line that's going on, but sometimes there's like weird stuff, like none, not irrefrencible or something. And you don't know what's going on, but now it'll in three 11, it will point to exactly what part of the line has the error, with little, little carrots underneath pointing

exactly where it's at. That is actually super cool. So like the example you got on the screen here on the announcement, you've got multiple objects being accessing their fields, like 0.1.x, 0.2.x. And the error is none type object has no attribute X, which is probably the most common error that you'll ever find in Python. But what I like about it that you're pointing out here is like the second object is the

one that is none. And it actually highlights, no, no, not the first one, the second one, because there's nothing about the error message that would tell you which of these two things was the problem. Yeah. That's awesome. Yeah. And it's, it's deep into the, so if you have a deep stack trace, it'll show you exactly where into it. And even like there, there's another example where it shows like, deep into a dictionary, deep dictionary, D reference or something, right. And it, and it

points out exactly which index is the one that's messing up. so that's pretty amazing. also even math, arithmetic expressions, like a division by zero, you've got multiple divisions, which one is the problem? And it'll show you exactly which one it is. The thing I love about this,

change is this is one of those things. This is absurdly difficult. Like this is like acres of computer science and a bunch of people working together on this for, I couldn't even imagine how long it took them to do, to make something, which is just a beautiful little incremental improvement to our lives as Python developers. But if you, if you, I think the release notes actually talk about some of the internal changes they had to make that to get this to work. This

is like really deep stuff and it's totally worth it for what you get out of it. But it it's, I think, I think it's easy to look at this and think, okay, that's a reasonably sensible, small change. And this was not a small change at all. And I think it's going to dramatically increase the on-ramping of new people into Python because, um, being able to like figure out what's wrong with your code, that's, you know, basics.

I mean, some of us old hatters, are used to digging into like confusing tracebacks, but, um, some new people are not. So if we can make them less confusing, that'll be great. Right. When I work with new programmers, it's so common. You get it, they get a traceback and they freeze because this utter, utter meaningless junk has just shown up on their screen. And what

are they supposed to do with that? And here it feels like this is just such a huge improvement because at least it's pointing to the bit in the giant blob of text that they should be paying attention to. Yeah. Lovely. Yeah. I want it in 3.10 though, but we have to wait till 3.11. From futures, import nice stack trace or trace back. Yeah. Very cool. All right. So Simon, you got the third one. Tell us all about it. Okay. So fly.io, a hosting provider who I've been,

they launched about a year ago. I've been following along because they're doing some really interesting stuff around hosting Docker containers and all my stuff is in Docker containers. So I'm always looking for things where I can throw a docking container to host online. Their secret sauce is that they do geographic hosting. So you can ask them to run your container in like Tokyo and San Francisco and London,

and they will do that and they will direct traffic to the closest version of that app. So it's this thing. I worked at Eventbrite for many years. And one of the things I was always trying to figure out was, okay, could we run Eventbrite close to our users? Could we have like European, a database in Europe and a database in New York and give people a faster experience that way? Incredibly difficult to do.

Right. But what a lot of people do is they do CDNs. So the static content, but then there's one server somewhere that is really the one, right? That's the problem. It's the database, it's the application code and then it's the database server, especially. And so what fly.io are doing is making it so much easier to do this, that you could start a project and have it geographically distributed from day one without

having to think particularly hard about it. So I like that about them. But then they wrote this, this, this article came out within the last week, I think. And it talks about their plan for multi-region databases. And in that case, they're talking about Postgres and this desire to have Postgres data,

have like Postgres databases distributed around the world. And so when you're doing that, splitting up, you're having rights to multiple places remains incredibly difficult, but a very common pattern is you say, okay, we're going to have the leads database is in, I don't know, New York and that all of the rights go to that. And then any of the reads get spread out to a replica database that's running in different

places around the world. And that's still a really difficult thing to set up with the geographic load balancing. So what they propose is basically run your application all the way around the world and set it up so that if anyone tries to write to the database and they're not talking to the leads database server, the error gets caught and the application server replies to fly CDN and say, it says, hey,

we run this request against the leader database in New York. And so the user doesn't see anything at all. The user attempts to do something and it works. And what's actually happened is they tried to do a right against Tokyo. Tokyo said, oh, we can't handle rights fly invisibly sort of internally redirected to

New York. And the right happened against New York and the result came back. And so this takes geographically distributing your database reads, which used to be, I mean, I was thinking it was going to be a team of engineers for six months to get this working. And it's just baked into their platform. It's this incredibly elegant piece of sort of systems engineering design that they've done. And I was fascinated. I've banged my head against this problem for so long and they just solved it.

You know, they just said, hey, here's a way it will work. We've shipped it, try it out. I, as I, as something of a architecture nerd, this really fascinated me. This is fascinating. Yeah. And I can see just, you know, we've got like the retry decorators and stuff for various Python functions. Like I could see almost a, you know, like retry the right decorator that you put on them. And it just goes, it catches the error and it just

goes, nope, we're going to send it everywhere it goes. And then, then return the result, right? Like Yeah. And it's basically put decorators anywhere you're going to ever do a right and you're good to go. Exactly. And in fact, they've even got example code for Ruby on Rails. We don't even have to do that. They catch the database error that says, you know, you tried to do a write in a read only transaction and they turn that into an HTTP header that replays it against the lead region.

And that's it. It's like this it's in, on the one hand, it's kind of an awful, clergy hack, but it's also genius. Like this is taking six months of engineering work and turning it into add these five lines of code. Now your application works all the way around the world. It fascinates me. Yeah. This is pretty interesting. Yeah. They also, I've got, there's one other link in the show notes. There's a second article they put out

a few days ago, which is just doing something. It's more about using Redis as a cache in your geographical data centers. So you can have a local Redis, like, because I mean, their argument is people in London tend to be interested in other things that people in London are interested. Ditto for Tokyo. So actually distributing your cache by city normally gives you really good cache hit rates. But they also pointed out that, and I didn't know that Redis could do this. Redis can be set up to

allow rights to supposedly read only replicas. So you can have a local cache that you're writing to and reading from, but still have that leader Redis in your main data center that can send rights out to all of those replicas. So that gives you cache invalidation from a central point. You can, in your sort of

lead Redis, you can say, "Okay, everyone delete the cache entry for whatever this thing is." And all of those replicas around the world will then delete that cache entry, even though normally they're acting independently. And yeah, it's, again, this is for, if you're a systems architecture design nerd, the stuff that they're doing is so interesting. I think it's interesting, and I'm not one of those. Maybe you are and you didn't realize.

You will be next year. You will be next year. Fantastic. Yeah, this is super cool as well. And yeah, it seems really useful. You know, and it's perfectly in line with like, let's take our app and put the logic in multiple places. Because that person is unlikely to move from Tokyo to Virginia during a session. But once they start in one place, they're going to stay in that place. And so the cache would reasonably just have like their local data on that one instance, right?

Yeah. Yeah. Cool. But maybe your CDN or not your CDN, your CMS is like generated a page and everybody needs that always to be in sync, right? There's that global data as well. Yeah. So very cool. I like this. Check it out. Indeed. Indeed. Well, let's talk about unicorns. I love unicorns. So unicorns, the magical creature. And Simon, I'm so glad that you're here because we can get your thoughts on this, even if you maybe haven't been like deep down in it.

So not too long ago, we talked about HTMX, which I'm still a big fan of HTMX. It's a cool like sprinkling of magic onto JavaScript stuff onto your page to make it more interactive. But if you're doing Django, HTMX is very relevant, but there's also this thing called Django unicorn at Django-unicorn.com. It's a magical full stack framework for Django. So the idea is that you can create these templates, these interactive templates without going and rewriting everything in like some front end

framework, like React or something like that. You can skip the JavaScript build tools because you know, you've got a lot less of that. And you can skip a bunch of serializers and just use Django for like the API bits. So you install unicorn, you create component, and then at the top of your template, you put load, you know, percent load unicorn, and then you can just give it a, one of these names. So for example, here's a little task. Task one is tell people about unicorn.

I can add that as too many will tell people about unicorn. And you can see like this cool little thing is interacting and it's not a refreshing the page, right? It's like a front end framework type of thing. But the way that you write it is you just put some extra complete pieces on there, like unicorn colon prevent, submit, prevent, and we're going to do this add function instead. And if somebody hits the

escape key, we're going to change the value. And you know, that's not JavaScript. Those are just HTML attributes, but they turn into JavaScript, right? Which is very cool. So, and then you just put your regular Django template business down and, and off it goes. And it turns it into basically something that's way more front end framework friendly. Simon, what do you think? So as far as I can tell, the, the real magic here is that they're using, they're doing the trick

where you render the HTML on the server. In this case, use reusing your Django template. And then the, they send back JSON with a blob of HTML in which you then essentially write into an inner HTML to update the page. And I love this pattern. Like, this is, sort of fun. I I've always been a big fan of the progressive enhancement, method of writing JavaScript where you get the stuff to more or less work without any JavaScript at all. And then if there's JavaScript, then you get in page, page

updates and all of that kind of thing. but there's also one of the problems I've seen with, all sorts of lots of engineering shops that try and do that is that you're not writing your templates twice. You have the Django templates that know how to do something, and then you have front end templates using react or handlebars or whatever that know how to do something. And you have to keep those in sync, which is an enormous waste of time for everyone involved. So what they're doing here then is

they're handling that they're cleaning up that inconsistency for you. You write a, you write a Django template. They can then render, they can use that template in Python code to generate just that fragment of HTML, send that back and have that displayed on the page. So yeah, I think this is a really interesting approach. I've not spent much time with Django unicorn itself, but,

it also reminds me a bit of the, I think it's called hot, hot, hot wire. The, Ruby on rails community built this, this very exciting, framework again, against these kinds of principles, just shipping blobs of HTML back and forth. I feel like it's, something like the, the mad rush towards single page applications over the past 10 years, is mostly resulted in applications that load slower and, take, take, take longer for

people to build. And they're so inconsistent and they make me so crazy. For example, I'll go to like a bank or something and I'll say, all right, I'm going to run my one password, pre-fill the page and you'll see it fill out the page. And then you try to submit it. It goes, please fill out this field. And there's clearly like an email address or something in there. What do you got to do? Go put a space, delete the space. So the JavaScript event triggers because

they're like, not really, not really HTML. It's all that junk. And it's just like, yeah, you know what I'm in. But it turns out what people actually want is they don't want a full page reload. Like anyone who's getting into single page apps and so on really, they just don't want that flicker when the browser reloads everything. So using this trick where if JavaScript is available,

you update a section of the page using stuff that came back from an Ajax API totally works. And that, that feels like the model here and also the hotline model from Wales. Exactly. Yeah. So the HTMX, the hotwire and this, it's all about, let's not write new stuff. Let's just take the views and the templates already doing their magic. And let's just put the little pieces in there to make them dynamic, which I'm all about this. This is great.

What I've missed is why is this a Django thing? Is it, is it because it uses the Django templates or is that? It looks like it. Yeah. It looks like the, the magic here is that it's using Django templates. It's because it has its own. And the models. It provides its own views to us because it needs to provide views that have provided JSON API where you can send it data from a form. It then renders that Django template in Python code

and then sends you back the stuff. So there's two sides to this, right? There's the Python Django view functions they've written, but they've also written a sort of eight kilobytes, I think of JavaScript that, that, that, that hooks it up on the front end. Cool. Nice. Yep. Yep. Very neat. So not very much code at all to get your Django to become more dynamic, which is great. Yeah. So, our, I don't think unicorns are blue. I'm not really sure what

color unicorns. I feel like they could be any color. Like they might be rainbow, but, but this, that actually, that's not a rainbow. It's not a rainbow. I want to, I want to talk about blue and I'm, I'm, I think I'm, I think I'm ready, to have tomatoes thrown at me or something for bringing this up. but so blue is, is an alternative to black. anyway. so I love black. I think black's awesome,

but there are times where you can't use it. and in the, for specific reasons. And, I'm thinking here may see basically about the decision that black made to default to, not a default, but enforce, double quotes on strings instead of single quotes. There are some code bases where there's already a standard to use single quotes. And then there's also code bases where there's so many strings that actually have mixed quotes. So you've got, single quotes and then double quotes

inside. And you know, mine end up mixed sometimes because if I want to put quote something in the actual string, I'll use single quotes on the outside. But if I'm going to say it's a good idea, I'll put double quotes on the outside. So I don't have to escape the single quote. You know, like if, if you're going to have one of the quotes in the string, then just go with the other one is often

something I'll end up doing. Oh, but actually, black does that for you. If you've got a string with a single quote in a string with a double quote, and that's the one time that black will use single quotes, which is kind of neat. Okay. Okay. That's good. Yeah. Good to know. I do like that, but okay. So if this is this, the sticking point is really just the quotes, then maybe try blue.

So blue is, is actually, I was worried that it was going to be a fork of black. It's not a fork. It's, um, it's sort of, in includes black and it like, overwrites some of the functionality and specifically just a few things. So the differences are the defaults to single quote strings, um, and except for, except for things with places where we love double quotes, like, doc strings and triple credit switch strings. For some reason, those look weird with single quotes.

So, I'm on board with that. it defaults the line lengths to 79 and I don't really care. Cause I always override that to like 120 or something like that. and I like black that black allows that overriding. and then the other thing that I didn't even think about, which is kind of nice is, uh, one of the things black does is, takes the hash. like if you have, hash comments on the, on your right side of your code, you've got like a block of them. Like, like maybe you're

talking about an entire block of code. So you have a block of comments, black alike, remove the white space in front of the hash, whereas blue will leave those alone. So you can have block comments on the side. that's really it. That's the only difference. and I, I think having this around is a neat thing. interesting quote from the doc is that they'd actually don't want to keep, uh, keep this project alive for very long. They'd really like these to just be options in black.

Yeah. I don't know how viral they'll get, but. I don't think that's going to happen. I think black is pretty hardcore guarantee. Yeah. like they're very into not adding configuration where they can still avoid it. Yeah. in researching this, one of the things I, somehow missed about black, maybe I haven't read the documentation in a long time, but a couple of years ago,

uh, it added, the ability to have format off and format on. So, one of the things, for instance, occasionally, not very often, occasionally I've got a large chunk of data set up in, in like a, a list or, or dictionary, something with, that I have called the, I have them aligned with comma alignment, like an old style CSV table. and black totally like a 19 80 C programmer. Yeah. Oh, sure. but black totally tears that apart, but for that you can, you can turn formatting off and, I appreciate that.

Oh, that's cool. That's a good feature. Yeah. See, it does have a little bit of, a little bit of give. but yeah. Yeah. That's cool. Yeah. Very good one. Very good one. So we got next. Oh, okay. so this is, there's a link in the show notes. This, this is an article that, somebody wrote about using Tesseract OCR to build yourself a searchable index of your screenshots.

Um, and I got really excited about this because Tesseract is like, Tesseract's been around since 1995, I think it's a huge, it was started off at Hewlett Packard and it's pretty much still the leading light of OCR in the open source space, but I've never managed to get it to work. And I've always wanted OCR that I can just run. And thanks to this article, I can actually use Tesseract now. So

I've got a couple of demos here. Can we see this? Yeah. So, I grabbed a screenshot just of the, a random slide from our conversation earlier and I can run, let's see, I think it's Tesseract, screenshot.png. I'll put it in a file called screenshot dash. You have to tell it the language that you're using because that affects how it does these things. And it's what's like 70 odd languages, I think. and I'm going to say, I want that as a TXT file and you run it. And now if I can't

screenshot.txt, this is the launch today, MongoDB 5.0. This is the screenshot I took of our conversation earlier. A better example even would be the, I took a screenshot of Python documentation just now. So I can run that same command, except I'll do it against Python docs.png, Python docs.png. I'll call it P screenshot. There we go. Okay. And now if I cat this, this is pretty decent OCR against the screenshot

of a pilot documentation. The really fun thing though, is that you can say you want it as a PDF file. And if you do that, it will give you a PDF, which is visually identical to the screenshot, but has selectable text on it. So you can copy and paste out of that PDF. So, the chap whose article is linked in the, in the, the, the notes, his trick is he has a folder on his computer that he saved screenshots to, and he has a automated script that then turns those screenshots

into these annotated PDFs, which means that spotlight on his Mac can now search them. So anything that he drops into that folder, a few seconds later becomes available to global search on his computer. I think that's a really neat trick. I love it. That's great. Then the, so yeah, there's so much stuff I want to do with this. yeah, it was Alec, Alexandru Nedlesu. I don't know if I'm pronouncing that correctly. wrote all of this up. but yeah,

it's, it's, it's, you can install it with homebrew. It's brew install tesseract. There's actually a Python library called PI. I think it's called PI tesseract, which I thought was doing complicated things with C modules. Actually, if you read the source, it's just shelling out to this command. So apparently that's the state of the art in, in Python, OCR is shell out to the tesseract command line tool, which I'm perfectly happy to do, you know?

Yeah. I really like this. You know, it's, if you've got a bunch of image data and you want to be able to do interesting things with it, like here's a really quick and easy way to do it. Right. Right. It's super simple. The, this article also, I didn't know that you could use the Mac, launch D I think you can use, you can add a launch agent, which automatically runs a script when a file is saved in a certain folder. So in this case, he's got a launch script that runs the, the, the

test rack to OCR stuff, but this is great right now. I can automate any folder on my Mac to do basically anything using this system that's built into the operating system, but I didn't know how to use. I didn't know you could do that either. That's great. That's cool. Yeah. Yeah. That's awesome. I feel like this is right up your alley, Simon, you know, with the, the data set, the dog sheep and like,

oh, here's this data we got from this, this automation. And yet I just can't dig into it. And now you can. I'm really excited about this. Although, so Apple photos, the next version of macOS, Apple photos is going to do OCR and all of your photographs for you. So you can search for text in pictures that you've taken. And, if it's anything like the current version of, our sex photos, all of that data is going to be stored in SQLite databases on your computer.

Like I've been, having a huge amount of fun building things against my Apple photos library, because they already run machine learning labeling against your photos. They know when you take a photo of a dog and they tag it with dog and the word dog is in a SQLite database on your computer. So once you've figured that out, you can run SQL queries against photos you've taken and say, say, show me every photo I've taken of a dog that was in San Francisco on like in the month of May.

And you get results back, which is crazy interesting. Yeah. That's pretty cool. Yeah. That's super cool. I love the stuff that you're doing with that. Is it just local or is there, are they caching that in their own databases as well? Oh, well, so they synchronize it all. So if you're using iCloud, your photos are synchronized up to their servers that you take a photo on your phone, it shows up on your computer automatically, but all

of it's the actual local data storage is all SQLite database files. Apple are really big into SQLite. So yeah, there are just these files littering your computer with your address book in there and all of your iMessages and all of your photo metadata, it's just sat there waiting for you to dig in and play with it. Nice. With dataset, probably.

Right? Yep. I've got a script called, I'll add it to the show notes. I've got a script called Dog Sheep Photos, which uploads your photos to your own S3 bucket so that you can actually link to them and embed them on web pages. And it extracts all of that SQLite data into a more usable format. So yeah, I've got a online database of all of my photographs that I update every now and then with the script. And it works. It's phenomenal what you can do with it. Cool.

Out in the live scene, Brandon, hey, Brandon says, this is fantastic. Definitely excited. And also taking a step back to yours, Brian, David Colton. Hey, David says, I'm using double quotes now in black, but my typing has not evolved yet to double quotes. So you just pass it through the single quote to double quote compiler process called black. And then you got it all adapted. That's nice. Yeah. I've saved like black has given me back. I estimate 5% of my program typing time used to be worrying

about indentation and such like, and I got all of that back. Like, thanks to black. I never even think about how I indent or style my code at all. I just say, I, I, I'll literally write horrible run on lines that go on for ages and then run black and it formats it nicely. And I forget about it. It's, it's wonderful. It's fantastic. That's cool. Yeah. Great. Um, got any extras for us, Michael? Uh, you know, I do. I always do. Unless I have an extra, extra, extra, you're all about it. Then I

guess I still do. So, we talked about strong typing last time, which lets you do cool stuff like go and put a decorator onto a function and say, well, this one, you know, if it has type and annotations or type information, like Python itself just does, if you put at match typing the decorator on there, it'll verify it runtime that you said it took an integer and you actually pass an integer, not a list or whatever to that parameter. Right. Yeah.

Well, Felix, who maintains this project reached out today that actually does a whole lot more that you should check some other things out. I just wanted to highlight a couple of things that he pointed out one. If we, you know, we're all familiar with the named tuple and you, you say the type name in a quote, and then you say the fields or the elements attributes in a list, either

space or comma separated, like spell, mana, fact, and so on. So this one has a typed name tuple where you can put the type information in very similar ways to what Python would have like colon, str, colon list, and so on. And then you get actual type runtime validation that your data going into your named tuple is actually the type of data you expect in your name tuple. Oh, nice. Isn't that neat? That's good. Yeah. Yeah.

Yeah. So there's that. And then also, I love this about our show. It's, it's kind of blows my mind that this, this is how the world works. And I really appreciate this. Everyone who plays along, we'll say things like, oh, I wish we could specify indexes in Beanie. And then like the next episode, we're like, Hey, look, Roman added a way to do indexes in Beanie. And I said, this is awesome that it applies to

functions, but why couldn't it apply to classes? It's basically the same thing. And so now six days ago, we have a new feature. You can also apply strong typing to classes as well or something like that. So well done. Well done. Is it because you asked for it? Because I mean, I asked for single quotes in black and I didn't get that, but... Well, I mean, it also may depend on the size of the project. The more input they get, the less

influence any individual statement may have on it. Right. Yeah. Anyway, I feel like thanks for working on that and the extra information there. Yeah. I actually, one other thing. Yes. I, I have finally, I've been working to make sure that we don't have to have one of these completely useless, dreadful talks on technology. Our site uses cookies. Here's our cookie policy. Do you accept our cookie policy or do you not accept our cookie policy? AKA, would you

like our website to work or would you like to go away? Like that's kind of what the button so often means. Right. and so I thought I removed all the analytics. I removed anything else that we might doing third, be doing third party. We're good. And I went to Python bytes and I'm like, wait, there's, there's double click. There's Facebook, there's Google. There's like, what is all this stuff? And we started including the live stream YouTube in bed and it started bringing back. And I'm like,

why would Google be putting in Facebook? That sucks. And there was also the discus conversation stuff that people haven't really stopped using. They all just go and chat on the YouTube streams. Now they want to have a live comment type of thing. So I'm like, well, I'll just take that out. That got rid of the Facebook one. and then, but what do you do about, about that? So I, instead of embedding the YouTube player, I said, I'm going to figure out a way to get the

picture automatically from YouTube, the poster. And then when you hover over it, it just has a play icon. It says play on YouTube and it opens up a new window. And I thought I was all clever by just putting the image there, but serving it from Google. No, there's now like the YouTube image servers putting tracking cookies on our site. I'm like, well, come on. Why is this so hard? So now on the server, we use requests. We download the image anytime it has to be shown on a page, put it in MongoDB.

And then if you pull it, we serve it back out so we can like strip the cookies, the tracking cookies out. Nice. And now, now when you look at the tracking content, none detected on the site, but why, why world does it have to be so hard? I just want to. Isn't it amazing how it used to be YouTube embeds were the absolute gold standard for embedding video on a webpage. Like that, why would you do anything else? And now actually I'm beginning

to think, you know what? Post the video, the .mp.mod file or whatever yourself and stick on an HTML5 video embed. And that's probably a better experience for your users as well. Because you know, when they click the video on their mobile phone, it'll play full screen and they won't have to hop through to the YouTube app and all of that kind of thing. Yeah, absolutely. Yeah. So anyway, just quick shout out, like this is

taking several passes, but I think it's finally 100% no tracking. I mean, we weren't putting there before, but like it was seeping in from just like what we might include on the page as content. Right. So anyway, there you have it, Brian. That was my weekend. How was it? Nice. Well, thanks. I appreciate you doing all that work for us. Yeah. David Colton has the wash hands emoji. There we go. We're all better. Yeah. Well, I've got no

extras. Simon, do you have anything extra you want to share? I've got one. So Textual is the, you know, and Will McGugan, who's working on Rich has been building Textual, which I know you've talked about on the podcast before. What I would encourage people to do is pay close attention because I've never

seen a piece of open source software developed this quickly. Like every day he's posting this video where he's like, oh, and here's the new feature where today he posted a video of it doing full like tree view on a file system, which you could interact with with your mouse in the terminal. And when you clicked on a file, it would open it in a separate panel with, like with, with syntax highlighting. It's, it's absolutely astonishing. It's like turning into one of the better ways of building a

GUI application and it's running in, in text in the terminal. We can almost have just a section of the show called what's, what's Will up to. You really could. Absolutely. Yeah. He's, he's re implemented CSS grid, the CSS grid mechanism for terminal applications. It's brilliant. And yeah, I'm just having such a great time watching him do all of this stuff. And he seems to be live streaming it. I don't think so, but he posts like little five minute videos on Twitter every day of the stuff that

he's doing. But I, I feel inadequate watching him work this fast, but just saying. It's such a delight though. It's like he was, he was born to build this piece of software and now he's building it and we all get to watch him do it. Yeah. That's great. Yeah. Henry Schreiner out in the live stream says textual is

amazing. Indeed. It's, it's quite, quite something. Yeah. And I know, I remember when he was trying to name it and textual didn't even come up on my radar as something that might be possible, but it's, it's so obvious now like graphical and textual. Yeah. It makes sense. It's cool. So, hey, how about a joke? Maybe. Oh man, I got some jokes for us. Two jokes. The one, I'm not really sure how to convey it,

but I, yes, I'll do my best. I want you to sing. No, man, this is you. This is you, bro. All right. So first one here is, I could definitely do this one. This one is, from John on Twitter, but pointed out to us by Nick Moore, who was previously on the show not too long ago. Thanks, Nick. And this one poses, I think also this is perfect for when Simon is on the show. It says, what do you get when you select star from goblins, dragons, elves, and comma unicorns, a query tale. Oh my goodness.

It's a fairy tale, a query tale. It's bad. It's terrible. It's bad. Oh, wow. Um, well, I wanted to share one that people could actually share with their, this isn't in the list, but one that people, I just read recently, people might be able to share with their kids. Um, in the Northwest, we've got, Sasquatch, right? So, you know what they, yeah, what do they call Bigfoot in Europe?

Big meter. Oh, it's pretty bad. quick tip. If you're ever near Santa Cruz in California, there is a Bigfoot museum in a log cabin in the woods outside of Santa Cruz called the Bigfoot discovery experience. And it is not a joke. It is very serious. And there is a man there who will take you through all of his evidence for big, Bigfoot. And it takes about an hour. He's got maps and plaster casts of feet, footprints and a map with pins on it. And it's fascinating. I could not recommend

it more. Yeah. I wonder if the COVID pandemic has affected the Bigfoot population. Oh, you, you should, well, go, go, go, go. You can call him up and ask him while I was talking to him. He got a phone call to answer questions about Bigfoot. So he will, he will answer your calls. Yeah. All right. Hey, Brian, your joke got a grown all the way from Australia. Nice. What was it mine? I'm not sure. It could have been either. Honestly. Yeah. I think I'm going to go with the meter one.

They were both pretty bad. All right. I'll see what I can do this with this next one here. So if, if you're a kid of the nineties, I guess it's probably the time there's a pinky in the brain. And apparently on one of the 10 places I have to write your name, I typed it too quickly and wrote brain. Yeah. And Brett Cannon caught it. And so, so he, he did a take on pinky in the brain and it starts out. What do you want to do today, Brian? Same thing.

We do everything with every Wednesday, Michael help Python take over the world. It's Michael and the brain. Yes. Michael and the brain. One's into testing others in the GUIs. They're both into making Python seem sane. They're Michael. They're Michael and the brain brain brain. Yeah. Yeah. Fantastic. I love it. Phenomenal. We need to have somebody that's got like musical talent to actually put this together as something. So anyway, yes. Someone who is not me because it won't come out.

Well, so we'll put in this with the lyrics in the show notes. Um, I think we should leave them there so that we are accepting submissions. Yes. And if they are, if they pass, we may actually play them on one of the next episodes. Oh, I'd love it. Yeah. Could be the new theme song, Brian. Yeah. I'm getting tired of the old theme song. Yeah, exactly. Which is no theme song. All right. Well, thanks. Uh, thanks a lot for, uh, showing up Michael and thanks Simon. Um, this was fun.

Thanks for having me. Yep. You bet. Bye everyone. Thanks 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. Get the full show notes over at Pythonbytes.fm. If you have a news item we should cover, just visit Pythonbytes.fm and click, submit in the nav bar. We're always on the lookout for sharing something cool.

If you want to join us for the live recording, just visit the website and click live stream to get notified of when our next episode goes live. That's usually happening at noon Pacific on Wednesdays over at YouTube. On behalf of myself and Brian Okken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Transcript source: Provided by creator in RSS feed: download file