Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 213, recorded December 23rd, or Anthony, Anthony Shaw here.
Is this December 23rd or 24th? You tell me.
It's the 24th, it's Christmas Eve.
Yeah, of course.
Yeah.
In Australia, awesome.
In the future.
Yeah, 23rd for us, Brian and me, here in the US, 2020.
And yeah, this episode is brought to you by us, so we'll talk more about that later.
And I'm Michael Kennedy.
And I am Brian Arkin.
And Brian, we got a special guest here, friend of the show, Anthony Shaw.
Welcome, Anthony.
Hi there. Great to be on.
Yeah, it's good to have you here. Thanks for taking time out of your holiday.
Yeah, no, it's a pleasure. It started last night, so the Christmas holiday has now started.
I'm off for two weeks. It should be lovely.
Yeah, it should be very lovely.
So, you've got, I think everyone on Twitter is jealous of all the pictures that you post
when it's like cold and gray.
And you're like, oh yeah, there's this beautiful sunny beach here in the summer in Australia
that I happen to be suffering through.
Yeah, it is.
Yeah, it's the middle of summer here and it's, yeah, beautiful weather and five minute walk
to the beach.
So, yeah.
Yeah, yeah, yeah.
Not too bad.
Cool.
Well, welcome to the show.
Happy to have you here.
I want to kick us off with this project called Django Ledger.
And Django Ledger is, have you guys heard of this?
No.
Yeah, so Django Ledger, you've probably heard of QuickBooks or FreshBooks or some of this accounting
software, right, that you've got to work with.
You know, it allows you to do either it's a desktop app or some kind of online thing where
you create purchase orders, you keep track of who your customers are, when they owe you money,
you accept payments, all that kind of stuff, right?
So Django Ledger is something like that built in Django, which I think is really cool because
it could serve multiple purposes.
One, you could take it and just run it for yourself or for your company and then customize
it.
Or you could actually use it to extend something, you know, build something on top of it, or maybe
even offer services in it, right?
If you're like Stripe, maybe it makes sense to integrate some sort of plug in here because
then you get 3% of everything that company makes basically, that's where credit cards
go, right?
So it's a bookkeeping and financial analysis engine for the Django framework, which pretty
sweet.
It's open source.
And if you look through its features, it has a chart of accounts and basically customers,
financial statements, has multi-tenancy support, has stuff for operations, for investing, has
bills and invoices and bank accounts, all that kind of stuff.
And yeah, pretty awesome, right?
Wait, multi-tenancy?
So is there like North Tennessee and South Tennessee or?
That would be Dakota.
I think Tennessee, there's only just one tenant.
No.
Yeah.
I think if you wanted to run this as like a platform as a service type of thing and you
wanted to offer up, if you wanted to basically create your version of FreshBooks, I feel like
that's what it would be.
If you're an accountant that serviced multiple clients, you'd probably do it that way, I
guess.
It looks pretty cool.
I thought there's a project called Ledger, which is open source, but it's not a, I don't
think it's a Python project.
I think it's written in something completely different.
So yeah, this is really cool and great, I think, for businesses who maybe have someone
who can set this up.
I'm guessing it's not available as a service.
You have to kind of...
I don't think so.
Especially, yeah, yeah.
If you look at it, it says this project is under active development.
It's not quite ready for production.
So this comes to us from Miguel Sanda.
I believe that's his project.
And I would love to see what the roadmap for stability is and when this is ready, when it's
coming out.
But it's basically all Python and HTML and just a tiny bit of TypeScript, like a salt
level.
Stuff that's coming is like inventory management, cash flow, taxes, all the fun stuff.
And Brian, even BDD is coming.
I don't understand.
Behavior driven...
Oh, behavior driven development tests.
Yeah, yeah, yeah.
And so they're also actively looking for contributors, especially anyone with financial or accounting
experience.
So if you're looking for some project to contribute to, you know, that'd be great.
You could contribute to this one.
It's not super well known yet, but I thought I would shine a little bit of a light on it because
it seems like it's a cool idea.
Well, it's even got invoicing and stuff too.
So I think this is pretty neat.
Yeah, absolutely.
So what's up next for you, Brian?
What do you got for us?
Next up?
Oh, so another web sort of thing.
But this ran across Flask Meld.
Flask Meld?
I've never heard of this.
So it's like...
Is it like a Vulcan thing from Star Trek?
No, the idea is like melding the front end and the back end.
Okay.
And the...
It's a pretty cool...
There's a...
You should click on the example article.
But yeah, that first link.
Right there.
Oh, right here?
Okay.
Yeah.
There's a...
It's basically...
It's fairly simple interactive stuff that JavaScript gives you.
But it's super fast.
And it just...
Like, you don't have to write the JavaScript code.
So the article in this article talks about how...
This is from Michael Abraham...
I think it's Abrahamson.
But he wanted to avoid writing JavaScript.
So he wrote a whole bunch of JavaScript to make this plugin.
So it's a Flask...
His first Flask extension.
But you kind of modify the Flask templates to insert these elements.
And then the elements just show up as like objects in Python.
And you can program them like that.
So all these elements are all implemented in Python.
Oh, cool.
And there's a little video on there.
But there's a demo as well.
So there's a working example.
And then the code for the example is up on GitHub as well.
So you can play with it.
One of the fun parts in one of his working examples is the drop-down for like a search.
So if you start like predictive search sort of thing.
So if you start...
The example shows states.
If you start typing states.
It'll like start filling in this list of states that you might mean.
And it's like super fast.
Nice.
Yeah.
Apparently it says right here that it utilizes web sockets and morphed them to create server-side rendered HTML
and swap out DOM elements without refreshing the page.
That's pretty killer actually.
Yeah.
And he's nice enough.
I think this is cool.
He's saying that he basically stole all the ideas from other people and put them together for this.
Or standing on the shoulders of giants, so to speak.
And there's a similar project called Django Unicorn for Django people.
I played with that a little bit.
The Django Unicorn is...
The documentation site's amazing.
It's got a bunch of examples.
But it seemed...
I don't know if it's the server that it's hosted on or what, but the Django example seemed a little bit slower.
It seemed like there was this round-trip thing going on, whereas the Flask example, Flask meld, was zippy enough that that would be completely sufficient for a lot of the applications.
I'm thinking of throwing in some interactive stuff.
Yeah.
This is really neat.
This idea of components is pretty cool here.
Anthony, what do you think?
Yeah, it's interesting.
I don't really use Flask, but in the Django world, quite a lot of components and stuff that I've pulled in and plugins to do interactive elements.
And each one is implemented completely differently, which is really frustrating.
Whether it's like a search box or a type ahead or like a multi-select field, just something that I need, which is not available in the standard forms model.
And each one tends to have its own JavaScript and its own collection of bugs.
And yeah, it is quite frustrating, to be honest, because you kind of think, oh, I don't need to write this from scratch in JavaScript.
I'll use an extension that already exists out there.
And then you kind of get stuck in, does it work in Django 3?
Right.
You know, what state is the JavaScript in?
And then you read through the source code and you stumble across security issues.
And it's like, okay, I wasn't, you know, there's a line between it's easier to write it myself.
And you end up, I end up just maintaining forks of all these extensions and then trying to get pull requests back into them to kind of fix things up.
But yeah, it's interesting to see, I guess, a different model for doing it, which, you know, could be applied to Django.
This thing brings me back to like the year 2001 web with ASP.NET web forms, which are like such a weird way to build web apps.
They kind of like tried to mirror desktop apps.
But you could put a little Ajax tag onto like a section and just that part of the page would just become like would automatically refresh and interact differently.
This gives me like kind of that feel, but like not old school web, but more modern web, which is nice.
Yeah.
I mean, like I was thinking of it and now a lot of people that are comfortable with like jumping into some JavaScript.
This seems silly, I'm sure.
But for instance, like me, I never touched JavaScript.
So if I've got a little and I've got like a little flask app that pulls up like test result data.
And it'd be great to just have a be able to get a little form there that says, hey, here's here's the version I want to see the results for and be able to pull that up.
And it it doesn't have to be pretty.
But this way I could implement it without having to go in and learn JavaScript.
So, yeah.
Yeah.
And I think this is super neat.
I'm with you, Anthony, on the tradeoff of grabbing some of these cool plugins, Flask, Django, whatever.
OK, this is just now adding functionality.
But then you've kind of got to understand its assumptions.
When does it work?
Like, why does it not quite work for what you're doing?
It's always a tradeoff.
I usually go for the vanilla version of the web and just build it myself until it's like really clear that there's a big benefit.
Yeah.
And you bring up an interesting point with the security concerns, especially anytime you've got dealing with input fields and stuff.
You've got to be careful with that.
Yeah.
Because they normally run queries in a database.
So you've got to kind of audit these things to make sure that they're not using raw queries and that they're not using weird templates and stuff like that.
All right.
They better be parameterized queries and not little Bobby table type queries.
Exactly.
Yeah.
All right.
Wrong one.
This one.
So what's next?
Maybe they're using even Bitwise operators in there, Anthony.
Possibly.
Yeah.
So my next link is Bitwise operators in Python by Bartosz Zacznicki.
And this one's really cool.
Actually, I think if you've ever used Bitwise operators or seen them in the Python language.
So this is where you'd use the pipe symbol to less than, less than, which kind of looks like two arrows or right, right, right, which is greater than greater than.
There's a XOR.
Is there another way to say XOR?
I just use XOR.
Oh, yeah.
Yeah.
That's what I say as well.
You didn't say XOR or something.
No.
Which is the hat sign.
I can't remember what that symbol is called.
The tilde is for not.
So, yeah, these are basically used for specific types in Python, which support Bitwise operators.
I like this article because they're rarely used in Python because you typically use types where you'd use a method to do a lot of these things.
Most of the time, you wouldn't necessarily need to work with data, which is binary.
So you wouldn't necessarily need to do these things.
But if you are working with binary data, they're super useful.
And it takes a bit of time to get your head around.
So I've got a couple of examples.
But, yeah, I love this tutorial because it actually doesn't assume you know anything about this topic.
It explains what the binary system is.
And it uses these icons of hands.
It uses emojis, kind of like a mini sign language to explain the kind of the bytes and stuff like that, which is really cool.
So, yeah, I really like it for that reason.
And it's really illustrative and kind of takes you through a few concepts.
And then how you can use these special operators for some of the built-in types, Python integers, bit strings.
You can also use them for byte arrays, which is really helpful.
And then it goes into things like bit masks and stuff like that.
So if you're ever working with any lower level data, this is super helpful to understand.
And also a little trick that I discovered a while ago was if you've ever used the enum built-ins.
So enum is in the standard library.
And if you wanted to describe an enum, you basically create a class and inherit from an enum type, which is in the enum package.
And you can do a whole bunch of things and just represent things as enums in Python instead of other weird ways of doing it.
I don't know.
Introduced in Python 3.7, I think it was.
But there's a little known feature in the enums, which is there's an int flag and a flag type.
An int flag is an enum, which you can represent as a flag, which means you can combine multiple of them.
So, for example, if you had a color enum and you had red, blue, and green, you could represent white as being red, blue, and green by combining the colors together.
Nice. Wow. That's cool.
Yeah, you probably wouldn't make a paint mixer in Python, but there's lots of things.
Flags, for example, like if you're representing system flags or compiler flags or any other kind of flags,
this is really useful because it actually implements all the binary operators.
So, yeah, flag and int flag are super helpful types, which are built into the standard library.
So, yeah, if you ever find yourself doing something like this or using a package,
which has implemented its own weird version of this feature, which is built in,
then you can upgrade it to this new syntax and then you're done.
Yeah. Nice.
Tell me, what does this auto do?
Oh, so in enums, if you're going to say, you know, you need to make a representation of the enum name.
And if it's an int enum or an int flag, you'd say, you know, one, two, three, four, five.
Like, so if I save it to a file or pickle it or something, then it's, this is the number that it represents.
So I can convert.
So if you converted the number one to your enum, it would know that red was one.
So, you know, you could basically use it for storage or something.
It's also really helpful.
Like if you're reading from XML files or JSON files or something, and there's like, there's a field which is stored as an integer,
but you know that it actually represents something a bit more logical, like enumeration, then you can, you can do it that way.
However, for flags, then because they support bitwise operators, they should follow the binary sequence.
So one, two, four, eight, 16, 32, 64, et cetera.
And once you get past 1024, most people start to forget.
So instead of working that all out in your head, you can just use auto, which is a function built into the enum.
And it will basically just work out what that value should be for you.
So you don't have to work it out in your head.
It'll let you like reorder stuff and not have to go, oh, now I want to just want to go one, two, three.
Or I want to add another one, but in the middle and it accidentally messed it up or whatever.
Yeah.
I think I might use those anyway, just to, just to indicate that the actual number isn't important.
It's just that they're, they're unique.
Exactly.
I think if you, if you don't assign it, then in enums, if you don't assign it, then it works.
But with flags, you need to assign it to something.
Yeah.
Just for people listening who don't necessarily see the code, the show notes, the idea is you create an enum class and you say like category equals just lowercase
auto open close.
That's the way that you sort of invoke this behavior.
Also a couple of questions from the listeners who are in the live stream.
Anthony Lister says useful for MicroPython or hardware, maybe.
What do you think?
Yeah, absolutely.
If you're, I mean, if you're working with like embedded systems or anything, I mean, Brian,
you're the expert.
Yeah.
You have to work with binary a lot.
So yeah, this is super helpful because you can represent stuff, which is different states
in the system.
Or if you want to read, read inputs and stuff from multiple channels, you're going to need
to use bitwise operators.
So both the bitwise operators are really helpful as well as the flags enums.
Yeah.
And Brandon Rainer says bitwise always confuses me.
And when I see it, I tend to roll my eyes back and ask why.
I'm sure there's reason.
But well, I mean, one of the things that comes to mind for me is, you know, you're thinking
about storing stuff in memory.
You know, if I wanted to store, say, a number or something like that, or, you know, you put
that into a Python number, that's like 28 bytes.
But if you create an array of bytes and you know the size of them are going to be, you know,
packed into little bits there, you know, like one to 10 or something, a whole bunch, you
could be way more efficient by, you know, creating little smaller containers and then bitwise
boring them together and whatnot.
Yeah.
Like bitfields, for instance, are a really cool thing, but even just straight numbers with bitwise
operators are important for hardware because you're like a lot of times you just have register
access to something or you have memory mapped registers and you, you know, just kind of read
those out and there may be a whole bunch of data.
So each bit might represent completely wildly different things.
So you can't really just check for equality.
You have to check, is this bit on or off?
Or I need to set this bit and leave all the rest alone and things like that.
Yeah.
Yeah, absolutely.
Absolutely.
All right.
Before we get to our next item, let me just let you know.
this episode is brought to you by us, things that Brian and I are doing.
And so one of the things we just launched over at Talk By Theen Training is our brand
new FastAPI course, which is a super cool new API framework that I think brings together
a lot of the things that we've been proponents of, you know, things like Pydantic,
Typense, Async and Await, all those, they all come together really nice over there.
So if you want to learn that, check that out.
Brian has some book on pytest.
So yeah, you can check that as well.
Links in the show notes.
The next thing I want to talk about, though, is why you should use an ORM.
Here.
There we go.
So Anthony, Brian, what do you guys think?
Raw SQL ORMs?
What are your thoughts here?
Well, I've been using like document databases lately and I don't really need an ORM.
So.
I'm with you.
So over there, maybe the R is a D, at least if it's a document database, it's an object
document mapper maybe.
But yeah, I find being able to work with classes like the way I think of it in Python
to be that's how I want my data to be.
And just something else can figure out how the database has to break that apart into relationships
and stuff.
Super neat.
You know, like SQL can go and say, create like if I had a user and the user had orders,
like they might have an orders list on the user class to create a new order.
You can just go to the user.orders.append the new thing and hit save, commit changes,
and then boom, you know, it like figures out that has to be inserted and the relationship
has to be said and all that.
Anthony, what do you think?
I use the Django ORM quite a lot and really like it.
Learning all the edge cases where it creates queries which are not super efficient.
But so I guess there's pros and cons.
Like if you were to write raw SQL, you know, sometimes if you know SQL really well, then
you can write more efficient queries.
However, there are typically ways around that.
The N plus one problem in Django.
The N plus one is the biggest problem for sure.
You want to describe the N plus one problem or take a shot at that?
Yeah.
So if you sort of have a foreign key and you reference an entity which might be a many
to many relationship and then you reference a property of it in the query,
not actually not in the query, but actually in the view, you mentioned something or you
look up a field which is part of a mapping to another table.
Kind of like I described, like if you gave a user to the view and the view wanted to know
about its orders.
Yeah.
More importantly, if you gave a list of users and it wanted to know about the orders for
each of them, right?
That's the real bad case.
Yeah.
So you had it for like, you know, which group people are in or like which team they're in
or something.
And it's just, it's a team ID.
And then you actually want to show it on the table as the team name.
So what ends up happening is that for every row in the table, it looks, it does another
query to look up the team name, even though they're the same across the board.
Whereas if you're writing that in SQL, I'd hope you'd do that as an outer join.
But yeah, so, sorry, not an outer join.
So yeah, OOMs are really useful in that sort of thing, but they do have edge cases.
For N plus ones, pretty sure you covered this one before, but there is an awesome tool called
N plus one, which you can run in your test suite.
So when you do all your integration tests with Django, it fails the test if it detects
an N plus one query, which I use quite extensively.
I think Adam.
Oh, I had not heard of this.
I mean, this is not such a problem for me because I work like Brian and document databases.
But to the extent that I work with like SQLAlchemy and stuff, like this is really, this
is the one you're talking about?
Yeah, yeah.
That's it.
Yeah.
P-L-U-S-O-N-E.
Yeah.
That one.
Yeah.
So I add it, I only add it in the test suite.
So you don't, you don't really need to put this into production.
So you just load it into Django.
You're assuming that you have tests, Anthony.
Yeah.
Well, that's probably a starting point.
So, or if you're a developer in an environment, you can just turn it on, but it would.
Yeah, it basically, it would print a warning and stuff like that.
However, there is a config option that says that it can raise an exception if it detects
one, which is awesome because when you run all your tests, it will fire off and fail the
test if it detects this type of query.
And the workaround in Django is actually really simple.
You just add another function to the chain, the query command, basically, which indicates
that I'm going to use this field in this other table.
So it kind of pre-looks up.
Right, right.
Please do the join or sub-query load or whatever it needs to do.
Yeah.
And the other thing about IRMs that I really like is the migration ability.
Like, it's fine when you initially design a system, you could, yeah, fine.
You can write your own custom SQL queries and stuff.
But, you know, within a week or two, you've added like five extra fields.
And actually, that one field you added now needs to be a different type or, you know, databases
are not static things.
Like, database structures change all the time in a real application.
So that becomes an absolute nightmare if you've handcrafted all your SQL, especially if you
don't have tests.
So, yeah.
I mean, for different database engines, there's different ways to do this.
I mean, SQL Server like has DAX.
So you can do DAX packs and DAX pack migrations.
But most of the other database systems don't have that.
Whereas if you're using the IRM, then, you know, Django and Flask and stuff would create
the migration for you.
And you're kind of pretty sure that you can add fields as you wish without necessarily
breaking things.
Or you can add types and you can describe what to do with the old ones.
So I think it saves so much time in just working with a live system where you're actually constantly
making modifications to the table structures and stuff.
And maybe you have different developers at different stages or you want to go back in the brand.
You want to say, I'm going to go back here and then work on this version of the app at this
stage.
You want to be able to go to just run the migrations and get to the right structure.
Yeah, I find it to be super, super helpful.
I mean, there are times where, you know, you want to get 100,000 records back from the
database and an ORM doesn't make sense.
But to me, I feel like, you know, you should 80, 90% of the time use an ORM.
And then there's that little edge case where something slightly different maybe needs to
happen, but you shouldn't start there because there's that 10% or 5% chance.
Yeah, most ORMs give you the ability to write a raw query.
Yeah.
And yeah, you should also check there's raw queries for SQL injection.
And I do have a tool for that.
Yeah, if you want to, you can run it through the Python security thing that I've built,
which will scan your code and spot where you've used the raw SQL functions in the Flask ORM and
the Django ORM.
And it will see if there's anything in them, which is pretty likely to leave you subject to
SQL injection.
Yeah.
Is that built into your PyCharm security plugin?
Yes.
Yeah.
Maybe.
Yeah.
I want to just mention this come like this conversation, although not exactly.
We didn't pull out much out of it, but comes from an article.
I wanted to highlight called why should I, why should you use an ORM object relational mapper
written by Kareem?
I'll leave that in the show notes.
There's a bunch of details that walks you through it.
So I wanted to cover this.
So people, if they're having this debate on their team or they're not sure which way to
go, or they're, they're new and they're like, what are all these funky acronyms about?
You know, they can check that out.
There's, there's the obligatory little Bobby tables joke in there.
I got to, got to go with that.
This is what your, your plugin is supposed to detect is this cool XKCD.
Cool.
You're not on the receiving end.
One of the things I'd like to bring up around ORMs is that like a lot of the ORM tutorials
assume that, you know, SQL.
And I'd like to see more tutorials on how to use an ORM and how to use it correctly
without any SQL examples.
Yeah.
You know, classes in Python.
Yeah.
Here's your way.
You don't have to know SQL.
Yeah.
I mean, I thought that was the point is that you can think in objects instead of in SQL.
So yeah.
Why do I got to learn SQL in order to understand the tool?
Sure.
Another thing that you can turn on that's helpful for the N plus one problem, at least with SQL
Alchemy, you can go to the engine when you create it and you can say echo, echo equals
true.
And it'll echo every single underlying SQL command sent to the database.
You can do something in SQLAlchemy and it'll say, here's what the actual thing is.
And if you've written your code well, and you've done the right join stuff, you'll just see like
a couple of entries for each page or interaction you're having.
You've done it wrong.
You'll see your, your output just scream by full of these things.
Like, ah, there's one of these problems.
So that's, that's a easy way as well.
Is there like a test way to like, like for instance, to check to see how many for
certain test sequence, how many, database interactions you've done?
Yeah, there is.
Yeah.
Um, there is in, there is in, Django, you can kind of hack a bit of middleware, which,
um, kind of catches SQL queries and stuff like that.
Um, it's not built in, but you can write it.
I think I've got code sample somewhere that does that.
Um, and just say how many queries this page executed.
Obviously it depends on, that's why it's important to see the database first with test data, because,
you know, if you just run it on an empty database, then typically, or you've got like one row or
something, then it's, it's going to be like, yeah, it's fine.
But then when you deploy it to production, like it's actually running thousands of queries
for every page.
Yeah.
Did you end up with what you got in the United States when we tried to roll out the, the healthcare.gov
and the entire system went down and yeah.
Like, like the, yeah, whatever.
They knew it was going to be the entire country using it and they didn't load test it.
Exactly.
Uh, one more thing, a comment from Mateus, it's also useful, when using Django to
add the Django debug toolbar or Django silk to be aware of what queries are going on.
And also I would add for pyramid, there's a pyramid debug toolbar and you can actually see the
underlying queries and how many of them there are and the timing.
It's, it's really nice.
Those things.
All right.
Well, let's move on to the next one.
Sticking with the database stuff, Brian.
Definitely sticking with databases, and SQL.
So, this one's from Simon Wilson and, he's got a tool called, library.
Well, yeah, sure.
Dataset, but, SQLite utils.
Um, this is, it's developed as part of data, the dataset project, but it's, it's usable
by anybody that uses, SQLite, SQLite.
And, it's a couple of things.
It's a command line utility, which, a lot of databases do have a command line way to enter
to query the database.
But I don't know if SQLite does.
Um, but this is a pretty cool command line.
You can interrogate, analyze tables and dump things and do all sorts of stuff.
Um, and even search, it's pretty useful and pretty simple examples.
Um, the, one of the things I really liked though, is the, the API that he has.
So there's a Python API to, I mean, you can use, like SQLAlchemy for instance,
to interact with SQLite.
But, another way to do it is to use the SQLite utils as a, as an API for, for SQLite.
And it's a pretty clean, simple, interaction.
And I think that's, it's something I'm, I want to try because it looks like a, I do need to
get back into some SQL, SQL database work.
And, I think this would help a lot.
Yeah.
This comes from the dataset found, it's like one of the foundational tools from dataset,
this project that he's working on, which is really interesting.
It's like empowering data driven journalism and data exploration across all these different
data sources by converting them all down to SQLite databases.
And then once they're there, you can explore them in interesting ways.
So there's like Twitter to SQLite, various other things to SQLite, Gmail to SQLite.
And then you can like explore all these different things, like geo JSON to SQLite.
Uh, what else have we got here?
There's just tons and tons of these things that plug into other stuff and then gets into this
common format.
And then he also has this cool tool called dog sheep, which builds on top of those databases
that creates like a personal search engine for your life.
So you could like plug in Twitter, you could plug in, your iPhotos library.
You could plug in your Gmail and then there's a search engine that just says search that.
So it's like the, one of the foundational building blocks of like, how do I get everything from
its original source into SQLite?
Pretty cool.
Yeah.
So Anthony, Anthony, what do you think?
Uh, I'm actually really interested about the next, link on his blog, which says I commissioned
an oil painting of Barbra Streisand's cloned dogs.
It's really nice.
Actually.
I kind of like it.
I thought it was a joke.
You actually did.
For gazing the tombstone of the dog that they are.
Uh, yeah.
Okay.
Interesting.
Yeah.
I'm not sure what it has to do with SQLite, but no, it's pretty cool.
I think, yeah, more tools for, journalists and stuff as I start to work with data and
data becomes more readily available or at least there's more of it.
So, yeah.
And people aren't necessarily, yeah.
And don't necessarily have the technical skills to work with massive data sets and stuff like
that.
So yeah, it'd be really interesting to, yeah, use some, some of these tools.
For sure.
Uh, Simon Wilson was one of the co-founders of Django.
I had him on Talk Python recently, but it's not published yet.
And we talked about data set and dog sheep and there's, there's just a lot of interesting
stuff that one of the stories that he tells, so people can listen to the episode, but he
has a dog, which may be this, commissioned thing.
He's like really got this dog that has a Twitter.
The dog has its own Twitter account.
So for example, some of the interesting stuff that he did was his dog in the Twitter account
will tweet when it goes to the veterinarian, like how much it weighs and stuff.
And then it will tweet pictures when it's on a walk.
And he was able to do things like we create a graph over time of his dog's weight by just
doing a SQL query against the dog's Twitter account that got pulled in like all sorts
of weird connections of like pulling data together that you just couldn't imagine.
So, yeah.
Anyway, really, really neat stuff there.
Okay.
Yeah.
All right.
People will check that out.
Um, and then you want to wrap it up with a, a talk that is very, work from home ish,
a conference that's very work from home.
I should talk from there maybe.
Yeah.
So, my next one is from the Pyjamas conference, which happened a couple of
weeks ago.
Um, and this is, yeah, lots of online conferences happening at the moment.
Um, which I kind of sign up for and look at the, you know, the talk list and think, oh,
great.
That'd be really interesting.
And then never actually get around to watching any of them.
Exactly.
Um, yeah, I'm just kind of struggling with this online conferencing thing.
I like the ideas are really cool.
The concept is cool, but the practicalities of it, yeah, especially like, I don't know
if it's different in our house, but, the, the conference run over a weekend and I just
wanted, you know, maybe an hour or so to watch some of the talks and things, but just sitting
down on the couch and turning the TV on, putting it on YouTube and then sitting and watching
talks.
And it was like, the kids isn't making so much noise.
My wife's like, why are you watching TV?
There's loads of stuff to do and I'm like, no, but I'm, this isn't.
And then is this work?
It actually is work.
I'm sure it is.
Yeah.
Sure.
It looks like work.
Yeah.
Um, so yeah.
I see pajamas.
There's pajamas up there.
This doesn't make it.
This doesn't feel like work.
Yeah.
And I definitely wasn't in my pajamas.
I had to get dressed because it was 10 in the morning.
Um, so yeah, I don't know.
I know I'm kind of talked about this and a couple of other people said they're having similar
challenges with these online conferences.
Just like, where do you fit them in?
Um, and if you actually go to a conference, it's like, you've got, you've got an excuse
that this is more, this is like, my time is now set out.
Whereas if I, if I was to say, I'm going away for a few days to a conference, that's fine.
But if I try to attend that conference at home, it's like, that's not, yeah.
Yeah.
That's completely different.
I'm going to lock myself in my room and watch TV for two days.
I'll be back.
Yeah.
Exactly.
It's not the same story.
Yeah.
Someone at work actually suggested that we have like a, a work hotel sort of thing where
people can attend virtual conferences.
Um, where, you know, especially if you're on, if, if they're late at night or they're in
weird time zones and stuff.
So even if it's just in your local city, you can go and stay there.
So you can at least dedicate the time.
Uh, anyway, the, so the pajamas, which I really wanted to attend, I managed to get through half
a talk.
Uh, and then I watched the other half like a week later.
Um, so that was not very successful.
Um, however, the talk was brilliant.
So I wanted to share a link.
It was called what the struct, by Zachary Anglin.
And it's talking about the, the struct library, which is built into, the standard
library.
I didn't really realize there was a struct library, right?
Like there is an array library that says this will hold floats contiguously.
Same thing for structs, right?
Yeah, exactly.
And I think, you know, Brian was talking about data classes before we went live actually,
but, you know, data classes are really cool.
Like if you wanted to represent, interesting structures and stuff like that, ORMs are
really important for this sort of thing.
But if you're working with binary data, reading the binary data and then converting
into native Python types, often, you know, you do C for that sort of thing.
And in C you just declare a struct and just say, there's these filled.
And you can just read and write that into binary, structures, which is kind of built
in, but sometimes you need to do that in Python.
If you're working with, actually, I've got some examples, but, so this explains what
the structure library is.
And it also has this macro language for describing what the underlying type is.
Um, and then you can kind of like pack and unpack it basically.
So you can say, here's my, here's my class or whatever, and here's the fields and the underlying
binary structure is a, you know, a float, a 32 bit integer or binary, Boolean, or,
you know, it may be a, a, a ASCII string or something.
Um, so yeah, there's basically all these like little, characters, for packing and
unpacking data.
Um, so yeah, it was really helpful.
Uh, if you're getting into this topic of working with binary data structures or something that
you've wanted to do, I recommend if you're on a Mac using a tool called Sinalize
it, or spice analysis, which is basically a GUI for working with binary data and it has,
um, a database of grammars.
Um, so you can basically like open a compiled executable or, you know, something like that.
Um, and it would be like, Oh, I know what this format is.
And it would then just represent it in actually something more understandable and you can edit
fields and hack around with stuff.
Um, it's great if you're doing capture the flags.
Um, or if you're doing some hacking for good, it's also really cool if you want to,
um, edit files, which are not in a human readable format, if they're in a binary format.
Um, and in the database, they've got a whole bunch of examples, including a lot of save game
formats.
So this is actually how I got into this topic.
Uh, originally it was when I was a lot younger playing games and stuff.
And I'm like, what is this file?
And then, you know, trying to echo it on the shell and it would be like, Oh, that's all
gobbled.
And then realizing it's all in binary.
And then, you know, trying to figure out if you open it up in a hex editor or something,
what it is.
And then, Oh, if I change this field, then I can give myself more gold or I can make my
character invincible or.
So basically like hacking the game by modifying the save game.
This end boss would be so much easier if I had a hundred thousand hit points or whatever.
So let's just increment that number.
Yeah, exactly.
I think modern games are a bit, they kind of put protections around the save game because
there's a lot more online aspect, but definitely older games.
You can, you can hack the save games and most of them give yourself whatever it is that you
feel like.
Um, so yeah, understanding binary structures is really helpful on the struct.
Um, you can even automate it using the struct module.
Yeah, nice.
Yeah.
There's also some good comparisons between like the values of structs and then tuples and name
tuples and data classes and Pydantic.
So there's sort of a spectrum that gets covered there as well.
Yeah.
Interesting.
Goes online well with the, the bit manipulation topic you were talking about.
It's like, for instance, very structured, structs are, are very
important for like message, systems like communication systems.
Uh, we have very defined, fields within each, with, within the, you know, we've
got 128 bit sequence or a thousand bits in there.
Each bit is a specifically assigned to different things.
Um, and those are, yeah, we, you definitely don't want to just like hope that it's right.
You have to put it exactly where you need it.
Yeah.
Yeah, exactly.
Like little network packet headers and things like that.
Yeah.
I'm using this at the moment cause I'm writing a disassembler.
So it's quite helpful.
Um, yeah.
Awesome.
Yeah.
That you're, you're definitely doing some low level stuff these days.
Uh, so I guess that's our, our main items for today.
Brian, you got some, some extras you want to share.
Yeah.
We got, poked by the Python software foundation that we should probably plan some events.
Um, because we're, we're, we've got a meetup, the, Python PDX West meetup, but I can't
access the building that we normally held it in and nobody would come anyway.
Right.
So, we're doing virtual.
So we've got, January 14th, we're going to do, we're going to start seeing what
it's like to do a virtual thing.
And I thought, you know, normally when we did the meetups before it was in the evening,
I don't really want to hang out in the, in the evening doing this, but a lunchtime would
be fine.
So I thought like a lunch, a lunch and learn thing.
So we're going to try that and see what it's like.
Yeah.
It's perfect.
Being virtual, you could just do it during lunch, right?
You don't have to go, okay, well I'm going to drive out, you know, fight the traffic or
whatever.
Right.
Yeah.
And I don't have to convince my boss to buy a bunch of pizzas.
Um, so yeah, exactly.
Exactly.
All right.
I got a couple of extras as well.
I ended up doing a FastAPI webcast with the folks over at JetBrains.
So people can check that out.
They want to go learn more about that.
And then also let me close my, our notes here, but I'll get them back.
Uh, Brian, you go next.
I got to pull this up somewhere else.
Uh, I just went.
So let's, sorry.
Yeah.
You got it.
Anthony, yeah.
Anthony, what are you up to these days?
What extra you got to share with folks?
Uh, yeah.
So, I'm going to be starting at Microsoft in February, which is big news for me.
Yeah.
Congratulations.
That's awesome.
Yeah.
I'm really excited about it.
Um, so yeah, I'm going to be the Python developer advocate working with, Nina Zakarenko.
So Nina's the, the current Python developer advocate and I'm going to be, yeah, helping
out.
Um, so yeah, really looking forward to it and working with a bunch of smart people over at
Microsoft.
So yeah, all things Python.
Um, do you know any particular projects you're working on?
So I'm not going to be, I'm not going to be, I'm not on the engineering team.
Um, and I'm definitely not working on Pidgin.
This has got nothing to do with Pidgin.
Um, contrary to the rumor, I guess.
Uh, you were hired to work on Pidgin.
That's what I heard.
Come on.
Yeah.
I, yeah, I'm definitely not.
Um, so yeah, this is kind of a side thing.
Uh, but yeah, it's kind of, definitely the, Azure platform and like using Python
and Python working with Azure and on Azure, VS Code and the Python extension and
just the tooling and around that, as well as the Python ecosystem with Microsoft products
in general or Microsoft technologies, and Python in general.
So, all things Python and yeah, really looking forward to starting on the 1st of Feb.
Um, and yeah, I have a long list of things that I want to, want to get stuck into.
Yeah.
I'm guessing that's remote, not just now, but permanently, right?
Yes.
Yeah.
That's super, that's super exciting.
Um, but that does mean Brian that he'll be somewhat in our neighborhood more often.
I suspect you'll come up to Seattle and Redmond sometimes when that happens again, when the
world is let loose.
Yeah.
I expect so when, we're not even allowed to lead the country at the moment.
Yeah.
Well, we'll see you in the Northwest once in a while.
Yeah.
When, when, maybe 2022.
Yeah.
What 2030?
We'll definitely see you.
2030.
No problem.
Also, from, from, the YouTube stream, piling says, congrats Anthony on the new job.
Thanks, piling.
Yeah.
So we should have like a, like a webpage with like a, graphic to show like how many,
like well-known Python people there are and the, like maybe a death star Microsoft sucking
all the Python people into Microsoft.
Yeah.
They're pretty evenly distributed.
Yeah.
No, it's all good.
All right.
Well, I feel like, might be time to wrap this up with a joke.
You think?
Sure.
Yeah.
So, this one came to us over Twitter from Lars and there was a, apparently a question.
Someone named Kate Maddox asks, what's the best programming language for coding your own
therapist?
You know, like we're all stuck at home.
People are depressed, have social anxiety or just anxiety about the world in general.
And Wes comes along with a, an appropriate answer.
What do you guys think here?
Python, of course, is the language.
So you can call it thera, I, E-H-E-R-A dot P-Y.
Yeah.
I think it's pretty much on par for our standard jokes though.
Yeah.
Um, might be better than average actually.
Yeah.
It could be better than that.
You need a little drum kit in the background, Brian, that you can.
Yeah.
Some symbols.
We'll set you up with like a little.
It's a business expense.
I'll totally get a drum kit.
Yeah.
Fantastic.
All right.
Well, Brian, thanks as always.
And Anthony, thanks for joining us.
Thank you.
Yeah.
Always a pleasure.
Yeah.
You bet.
And everyone listening.
See you next time.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at Pythonbytes.fm.
If you have a news item you want featured, just visit Pythonbytes.fm and send it our way.
We're always on the lookout for sharing something cool.
On behalf of myself and Brian Okken, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.