Transcript #63: We're still on a desktop GUI kick
Return to episode page view on github00:00 Hello and welcome to python bites where we deliver python news and headlines directly to your earbuds. This is episode 63 recorded january 31st 2018 i'm michael kennedy and i'm brian and as always we got a bunch of stuff lined up for you before we get to it let's just say quickly thank you to digital ocean for making this show possible thank you to joshua I wanna check out what they're offering, do.co/python.
00:22 I'll tell you more about them later.
00:23 Right now, I wanna hear a little bit about what's coming in Python, Brian.
00:27 - We've already talked about data classes coming up in Python 3.7 already.
00:32 And I was curious about exactly what that means to how it'll be to work with them and stuff.
00:38 And Anthony Shaw put together a tour of how they work, and it's a pretty quick read, but it's a pretty good thorough understanding of it.
00:49 I guess it's called a brief tour of Python 3.7 data classes.
00:53 And there's some exciting things.
00:54 Like one of the things is there's a lot of the default magic methods I'll put in place are like init and represent or repper.
01:04 I don't know how you say that.
01:05 And the dunder stir and dunder equal.
01:09 The equal one is the thing that I think is really kind of cool is that it's gonna compare all the attributes in order.
01:15 So if all of the elements of your data class are equal to another object with the same elements, they will be equal.
01:24 And that's not something that's normal by default.
01:28 So that's good.
01:29 - Yeah, actually, that's really cool.
01:31 And I wonder, I don't know, there's a couple things that are interesting to me here.
01:36 One is the default value stuff, the way that you configure the fields, The fact that there's type annotations coming as basically, are those required?
01:48 It looks like they might be required, not just optional.
01:50 - They are required, but if you don't know what a type will be, there still is the, in the types, there's an any type that you can use.
01:58 - Yeah, so basically, that's like the void star, or whatever, like I have no idea what this is, just it's a thing.
02:03 - Yeah, I mean, this is Python, so a lot of times you want it to be generic.
02:07 You don't know what the type's gonna be.
02:08 - Yeah, yeah, that's right, that's right.
02:09 It's pretty interesting.
02:10 So I do like these.
02:11 The other thought I had about these, looking through this, is I wonder if this means the name tuple is less cool these days.
02:20 - What do you mean?
02:21 - Well, one of the things I think that's nice about the name tuple is you can basically create a type and you say it has these fields, and then you have sort of typed access to it.
02:32 In the editors, you hit dot and you get a dropdown of all the available elements of that thing.
02:37 You can make it read-only, which is potentially nice.
02:41 what else? It has a nice string representation, has a nice hash and equals operator, right? All those types of things. Every one of those comes in data classes. And if you put a frozen on the data class attribute to say, actually, this is read only, then it also implements the hashing. It has the immutability feature like it. Once it is created, it looks like it is the sort of equivalent of a name tuple, but it's richer in the sense that you can have like default generated values, it has, it just seems a little richer than a named tuple, but it's the usage is pretty much the same.
03:15 I think in my case, I probably will use it.
03:18 I'll try to use it more to see how I like it.
03:21 But I mean, right now I use named tuples quite a bit.
03:24 And they're, yeah, they're very, they're very terse.
03:26 There's, you know, a couple lines of code, and you've got a new type.
03:29 Yeah, the one thing I do see here is like with named tuples, you can literally on one line have a type that it takes six arguments. Whereas this one, you know, it's certainly more verbose. But once it's defined, I feel like basically the use case is like this is a super set of named tuples unless I'm missing something.
03:47 Yeah, definitely think in the use case, a lot of places where named tuples are being used, data classes will be used instead.
03:53 It'd be interesting to see if there's any different performance for data classes versus regular classes. I think you can say use slots. Is that possible? I think that might be a thing.
04:02 That I'm not sure.
04:03 Anyway, if you can do that, that would actually have a real interesting impact as well, because that would probably use less memory than named tuples.
04:10 At least my testing has shown that it does.
04:12 Well, I'm sure that there will be somebody that goes out and does some performance analysis to give us that answer.
04:18 Yeah, it's a call to the audience, indeed.
04:21 Very cool. So these are coming, and that's pretty neat.
04:24 I have another piece of news for you related to this.
04:27 Okay.
04:27 So Python 3.7, development on it is sort of frozen in the sense that it's now out for testing and for usage, but no new features are being added to it.
04:37 So it's kind of frozen.
04:38 And Python 3.8 development started yesterday.
04:40 Wow.
04:41 Yeah, so I haven't started testing with 3.7 yet, or doing any of that.
04:46 Have you used it at all yet?
04:48 No, I've thought about it, but I haven't done it now.
04:50 Yeah, definitely something I want to get started on here pretty soon, because I think it's due to drop in June or something like that.
04:58 Yeah, it's in like a trial period to make sure the world doesn't break when it gets released.
05:02 Because could you imagine the pressure?
05:04 But yeah, it's supposed to officially come out in June.
05:07 But it's kind of, it got into its testing mode, which is pretty cool.
05:11 So if I ask you what was the most popular database in terms of deployments, what database would you guess?
05:18 Oh, I've fallen for this before. I'm going to answer Excel.
05:21 Excel. Is that actually, you know, I don't know, this one that I'm about to say, it was very likely to give even Excel a run for the money.
05:28 So everybody who has Python has SQLite, right?
05:31 It's baked in.
05:33 There's a whole bunch of things that are interesting about SQLite.
05:36 So it's like an in-process database.
05:38 If you want to do something relational, say with like SQLAlchemy or something, but you just want to ship a little app, you don't want to deal with like a client server model, SQLite is so super nice for that, right?
05:50 You just have like a little data file.
05:52 And I think we maybe talked about this a little bit before on a couple shows back, but one of the listeners sent in this thing, this series from Carnegie Mellon University called the Databaseology Lectures.
06:06 So there's a bunch of databases covered there and there are actually quite a few interesting ones.
06:11 And the idea is these are like hour, hour and a half long academic lectures by the creators of various databases about the internals of how they work.
06:20 And I think it's more or less like a CS sort of either speaker series or actually a course.
06:25 I'm not sure, but they got a bunch of luminary folks to come and speak about it.
06:29 And it's pretty cool. So they have like the guy...
06:33 That sounds like an exciting date night.
06:35 Oh, yeah. Yeah, my wife was pretty excited when I suggested that. No.
06:39 So there's Wired Tiger, which became the foundation of the storage engine of MongoDB.
06:45 They had that before it became part of Mongo.
06:47 Okay.
06:47 The one that I wanted to call out is the one by Richard Hipp, who is the creator of SQLite.
06:53 And it's like this deep look inside the architecture and trade-offs and design decisions of SQLite.
06:58 And so if you're interested in databases, you're interested in how SQLite works, there's a bunch of optimizations and trade-offs you can make around like durability versus performance.
07:06 There's a bunch of sort of deep dive stuff into here.
07:09 So I thought that was pretty cool to highlight.
07:11 I'll definitely check that out.
07:13 I also noticed that they've got even SAP in Oracle.
07:16 That'd be interesting.
07:17 Yeah, something to do with Berkeley DB in there as well.
07:19 So yeah, it's quite cool.
07:21 Yeah, but there's so much I'm not really sure I want to try to cover.
07:25 But if you want to look inside of like, how do the B-trees map disk and how do they deal with like power failure, transactional durability and all that kind of stuff, you want to see a deep look inside of that for databases in general, SQLite in particular, you check it out there.
07:40 I guess one, just as a teaser, one interesting fact that came out of there is SQLite is shipped as a single C file.
07:48 Yeah, that's cool.
07:49 I don't know how, like, two million lines? I don't know, like some insane number of lines.
07:53 They don't develop it as a single.
07:55 No, no, there's some process, some mechanism that detangles all the include statements and the various compile orders and all of that stuff, and it generates this one huge file with no dependencies.
08:11 But it's pretty wild to think of such a such a program is created that way. It's interesting that it's a intentionally no dependencies The whole thing is a little bit Unusual the way that the guy has created it and run it like instead of he was like well open source is good but actually I just want to make it like Nobody, this is a thing that just is the world and so he made it put it out there under Common domain or what's that called? Anyway, where you just say like it belongs to the world I relinquish all ownership of this thing. It is just now public domain, public domain.
08:45 Yeah, so it's pretty interesting.
08:47 Yeah, it is. Do you know what else is interesting?
08:49 Testing your code before you take down the system, or you charge a credit card and you didn't want to.
08:54 Yeah. Did we get this from a listener? I can't remember.
08:58 Yeah, this definitely came from a listener. I can't remember who.
09:01 Maybe I'll pull that up while you're having a look.
09:04 Okay, well, this is a project called dryable, a useful dry run decorator for Python. And the idea is that there's sometimes where you want to, you want to run your entire application, but there's pieces of it that you don't want to run all the time. Like, in their example, they've got, if you're accessing an outside database with requests, or you can or something like that, you can turn that off during your dry runs.
09:33 And I really like how generic this is.
09:36 So basically, you put a decorator, it's a dryable decorator you put on top of a function.
09:43 And then when you set the dryable state to true in your code, those functions just don't do anything.
09:52 And then they also have the option of specifying a default return value.
09:57 So during your dry runs, if the function that you're turning off is supposed to return something, or else the rest of your code is just going to break.
10:05 You can specify that there.
10:08 For testing certain systems, I think this is an awesome idea.
10:13 It's pretty cool. It's pretty easy to start.
10:15 >> It's almost like if I wanted to set up the mocking story for my code by using decorators and I could run it just even outside of a test framework, what would that look like?
10:27 It looks like this drivable thing, right?
10:28 >> The intent, I think, is to be able to just leave this stuff in your code.
10:32 So it's a very minimal impact.
10:34 And then you can just, if you want, you can just leave it there so you can always be able to do dry runs or something.
10:40 - Yeah, in your test code, you just say dryable.set true.
10:44 And then it just goes in this way.
10:46 So one of the things I was wondering about when I saw this, I agree that it's cool and I definitely like it, but one of the things that I was wondering is like, we have mocking and these other mechanisms for stubbing out stuff.
11:00 Like, where do you see this fitting in versus not?
11:04 >> A lot of times people, and I agree, mocking is definitely, mocking and monkey patching is often used for definitely for testing stuff.
11:13 But like, I don't know, for example, you could put together, we were doing different GUI applications we were showing the other day.
11:21 If you wanted to attach a GUI to a database system, you could have a mocked up database set to just let people play with user interface.
11:32 And that's not really a testing thing.
11:34 It's you're just using something with some dummy data in the backend.
11:39 Something like that would work.
11:40 - I see, like maybe some, if you're trying to build out the UI and you don't have the data yet, it would be really nice to just go, and here's some data to work with until we get there.
11:47 - Yeah, yeah, definitely.
11:49 - Yeah, okay.
11:50 That's pretty cool.
11:51 So I told you about DigitalOcean at the top of the show, and I'll give you a little more details.
11:56 They actually have some super exciting news.
11:58 maybe a week, week and a half ago, two weeks ago, I can't remember, but I actually spent a lot of time upgrading a bunch of servers because DigitalOcean is awesome.
12:07 They actually went and said, you know what, all that money that you're paying for the servers, we're just going to double all the things.
12:13 You have one gig of RAM and you're paying us $10 a month, all right, now you get two gigs of RAM.
12:19 You have one CPU and you're paying a certain amount, now you get two CPUs or two to four.
12:24 So they basically, not everything, CPUs not quite as much, but certainly, you know, disk size with SSDs, the RAM, to some extent the CPUs, they're basically doubling everything they offer.
12:36 So now you can get like a server with a gig of RAM and a CPU and 30 gigs, 50?
12:41 I don't know, 50 gigs of SSD for $5 a month.
12:44 How insane is that?
12:45 - Wow.
12:46 - Yeah, exactly.
12:47 So anyway, it's really cool that the new pricing that they put out, so definitely drop over do.co/python and check that out, because if you thought it was good before, like literally they doubled most of the things for most of the tiers.
13:01 - That's great.
13:02 - Yeah, so really nice.
13:02 And Python Bytes now delivers itself just a tiny bit faster and has a few more gigs of RAM to do it with.
13:10 - Well, that's good 'cause our listeners are going up.
13:12 - Right, we gotta keep up with the demand.
13:13 Thank you, everyone.
13:14 (laughing)
13:15 Speaking of demand, we got actually a lot of listener feedback for this show.
13:19 And I think that that was really great.
13:21 Like, please keep the recommendations coming on Twitter and email and so on.
13:25 Have you noticed I've been on this gooey kick lately, Brian?
13:27 - We kind of knew this was going to happen.
13:29 We claimed that there weren't any good solutions and then people told us.
13:33 - Yeah, I still mostly stand by that, but there are people doing really cool things and I just want to highlight them.
13:41 So a guy named Victor Domingos said, hey look, I'm not really much of a programmer.
13:46 I kind of, like an engineer or something, you know, he was doing something else but he needed to do some program to build this thing, right?
13:52 But I disagree with that statement.
13:53 I think he's quite a programmer building these things.
13:55 So he sent us three examples of some apps that he built in Python. And I don't know, do you click those and pull them up, Brian, and see the pictures?
14:05 I'm trying to pull up one now.
14:06 Yeah, so what's really nice is, like, it's all screenshots.
14:09 Which, by the way, if you have a UI framework and you want people to admire your UI framework, screenshots. Pictures, please.
14:15 Just describing how awesome it is in text doesn't actually make it awesome.
14:19 So, but these look like rich, interesting applications.
14:23 And I definitely think what he's doing here is quite neat.
14:27 Especially the first and the second one that we've linked.
14:30 So we've linked to three.
14:31 This is crazy.
14:32 PT Tracking is both, it's got both the desktop application, which looks nice.
14:36 And an iPhone version.
14:37 And an iPhone version.
14:39 [laughs]
14:40 Wow.
14:40 Yeah, it's pretty interesting.
14:42 I mean, like I said, this guy built some really powerful stuff, right?
14:45 Yeah.
14:46 Looks great.
14:47 What's even better is it's open source, right?
14:49 This is TKinter code.
14:50 He's like, "Look, you're giving TKinter a bad rap.
14:53 This is actually could be more nice looking if it's built the right way." And by the way, here's three open source apps I built that you can check out with screenshots, by the way, which is very nice.
15:04 So I just want to highlight that, say thank you, Victor, for sending these in, share the links he sent, because they are pretty inspiring and they're working examples.
15:12 - I did not know you could make an iPhone app with TKinter.
15:15 - I still don't even know how that works.
15:17 - I don't either, maybe I'll try this out.
15:18 Maybe there's some kind of PEP for it.
15:20 Like a PEP, what is that?
15:22 PEP 7225, make Python build desktop or mobile apps on iPhone, is that what it is?
15:29 What if there's like a way you could figure this out that we could settle this debate?
15:32 - There's PEP Explorer and it is by Anthony again, Anthony Shah that we gave him credit on the first article that we talked about.
15:42 But PEP Explorer, explore Python enhancements with a web interface.
15:47 It's got a search function and you can look at all sorts of stuff.
15:51 There's even, in the status, I don't quite get all the status ones, but there's an April Fool's status, which I didn't know about.
15:57 - That's pretty awesome.
15:58 - In 2009, they pretended that BDFL was retiring.
16:02 - We probably just scared people, actually, is really what happened.
16:05 Yeah, so not only do you find the PEPs that were accepted, but you can search and say, show me the ones that were either deferred or rejected.
16:12 You probably will learn a lot of interesting stuff by seeing what is rejected and why.
16:16 - Yeah, and then the ones that are still in draft form and everything.
16:20 One of the things I wanna, I had already picked this and then I was playing with it, 'cause the data classes that we talked about earlier, I cannot find on this little cool tool here.
16:31 So I'm not sure what's going on with the 3.7 stuff.
16:35 Maybe 3.7 just isn't in here yet.
16:36 - Yeah, maybe, and this is a search engine sort of thing with data backed on GitHub, right?
16:41 And so if anybody wants to say, oh, you're missing this one, PR.
16:45 - Yeah, so nice people do fix it and do a PR.
16:49 I just am gonna call them out on Python Bytes and say, it's broken.
16:53 - This one doesn't work, it's not there.
16:55 And I can't do a PR right now 'cause I'm recording a podcast.
16:58 - Yeah, definitely.
16:59 - Yeah, yeah, nice work, Anthony.
17:01 You know, enough to get a double feature, very, very cool.
17:03 So I wanna round this out with just a little bit more UI stuff.
17:07 If I'm gonna show you all those pictures of cool apps that Victor built, the other thing I wanna sort of pair with that is a TKinter tutorial from this, we got on Twitter as well from @likegeeks.
17:20 And it's basically, here's how you go through TKinter and create your first GUI application.
17:24 You don't really build anything too complicated or too advanced.
17:27 It's more like, let's put some labels and buttons and combo boxes and progress bars on and see what that looks like, right?
17:33 It's still like a decent distance from what Victor had built.
17:36 But if you were inspired by topic four, maybe topic six can help you take some steps in that direction.
17:42 - Yeah, okay.
17:43 Yeah, it's pretty comprehensive.
17:44 Like it really covers most of the widgets and how to use them and stuff like that in Python.
17:48 So yeah, pretty cool.
17:50 This may be the final thing we say about it, or maybe my own news actually will cover one more gooey thing.
17:56 Yeah, I think that we'll probably hear some more gooey things coming up in the future.
18:01 Yeah, yeah.
18:01 I'm okay with that.
18:02 I am too, and I think this is great.
18:03 Like I think the other area that's looking really strong, the more that I talk to people about this, is WXPython.
18:09 Yeah.
18:10 What I didn't realize is WXPython has a project called WX Python Phoenix, where it was reborn from the ashes of WX Python.
18:17 And there's like two versions of it, sort of.
18:19 So there's like a more modern version that I like conflated with the older version.
18:23 - Okay, didn't know about that.
18:25 - Yeah, I didn't either.
18:26 But the thing I'll tell you about in a second, did, how about you?
18:29 Any other personal news you got going on?
18:32 Anything cool?
18:33 - Not right now.
18:33 - Nice.
18:34 For me, this is like the week of the recording.
18:38 The recording.
18:39 So I'm recording six podcasts, talk Python, Python Bytes, I was a guest on a podcast, and also a webcast.
18:47 So I did like an hour and a half webcast where I rebuilt PyPI in MongoDB, which was really fun.
18:54 - Wow.
18:56 - So it was really, really cool.
18:57 And I even created this fake database with like, you know, hundreds of thousands of records to like make it act real.
19:03 It took like 15 minutes for the program to actually generate the database, but that was okay.
19:07 It was still good.
19:08 Anyway, so that was fun, I'll put a link in there.
19:11 This weekend, some friends were over, and they're like, "Hey, I'm trying to build "this little script, and it's almost working.
19:17 "Can you help me?" And I'm like, "Oh, this is a cool little CLI, "but do you know what would be better is if it was a GUI?" (laughing)
19:24 It's like, "Yeah, I know, but you can't do that "in Python, Cade." And you're like, "Yeah, hold on, let's pip install GUI, "G-O-O-U-I, that thing we already talked about." And that thing is slick, let me tell you.
19:34 Basically, you create one of these argument parser things from GUI, you say it takes these parameters, and then you say, get the parameters, and that actually shows the UI with all the widgets filled out, and the names, and the types, like this one is a combo box, it has these three items, like that's your argument, then it becomes just a combo box. It really is like just a few lines of code, it's awesome.
19:53 We've been getting a lot of people that have been using GUI show us their screenshots of something they made with it in just a few minutes, and that's pretty awesome. I really think the bang for the buck is quite high on GUI right now, and that's WXPython by the way.
20:05 Also, a quick announcement on the courses.
20:10 I have a bunch of courses coming up and more of them are getting planned all the time.
20:13 It's really fun.
20:14 But I just launched a sort of business option team purchase page.
20:19 So all the bundles and the courses and stuff at Talk Python Training now have a buy this for your team.
20:25 And if you pick like a however many people are on your team, it'll automatically apply like enterprise discounts and all that kind of stuff.
20:31 So if you wanna go in there and say buy this for 10 people, it's all totally self-service now.
20:35 - Wow, that's great.
20:36 - Yeah, so trying to make it easy for people to get more of that Python knowledge.
20:40 - Neat.
20:41 - Yeah.
20:42 All right, well, thanks, Brian, for finding all these things and sharing them with me.
20:44 - Yeah, thank you.
20:45 - Yeah, bye.
20:46 Thank you for listening to Python Bytes.
20:49 Follow the show on Twitter via @pythonbytes.
20:51 That's Python Bytes as in B-Y-T-E-S.
20:55 And get the full show notes at pythonbytes.fm.
20:58 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.
21:02 we're always on the lookout for sharing something cool.
21:05 On behalf of myself and Brian Okken, this is Michael Kennedy.
21:08 Thank you for listening and sharing this podcast with your friends and colleagues.