Transcript #63: We're still on a desktop GUI kick
Return to episode page view on github00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
00:05 This is episode 63, recorded January 31st, 2018.
00:09 I'm Michael Kennedy.
00:10 And I'm Brian Okken.
00:11 And as always, we've got a bunch of stuff lined up for you.
00:13 Before we get to it, let's just say quickly thank you to DigitalOcean for making this show possible.
00:18 Thank you, DigitalOcean.
00:18 You want to check out what they're offering, do.co slash Python.
00:22 I'll tell you more about them later.
00:23 Right now, I want to hear a little bit about what's coming in Python, Brian.
00:26 We've already talked about data classes coming up in Python 3.7 already.
00:31 And I was curious about, you know, 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.
00:43 And it's a pretty quick read, but it's a pretty good thorough understanding of it.
00:48 I guess it's called A Brief Tour of Python 3.7 Data Classes.
00:52 And there's some exciting things.
00:54 Like, one of the things is there's a lot of the default magic methods that I'll put in place are like init and represent or repr.
01:03 I don't know how you say that.
01:05 And the dunder stir and dunder equal.
01:08 The equal one is the thing that I think is really kind of cool is that it's going to 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 can configure the fields, the fact that there's type annotations coming as basically, are those required?
01:47 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.
02:00 Like, I have no idea what this is.
02:01 Just, it's a thing.
02:02 I mean, this is Python.
02:04 So a lot of times you want it to be generic.
02:06 You don't know what the type's going to be.
02:08 Yeah, yeah, that's right.
02:08 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:40 What else?
02:41 It has a nice string representation.
02:43 It has a nice hash and equals operator, right?
02:46 All those types of things.
02:47 Every one of those comes in data classes.
02:49 And if you put a frozen on the data class attribute to say, actually, this is read-only, then it also implements the hashing.
02:56 It has the immutability feature.
02:58 Like, once it is created, it looks like it is the sort of equivalent of a name tuple.
03:05 But it's richer in the sense that you can have, like, default-generated values.
03:09 It has...
03:11 It just seems a little richer than a name tuple, but its 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:20 But, I mean, right now, I use name tuples quite a bit, and they're...
03:24 Yeah, they're very...
03:25 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 name tuples, you can literally, on one line, have a type that takes six arguments.
03:36 Whereas this one, you know, it's certainly more verbose.
03:39 But once it's defined, I feel like, basically, the use case is, like, this is a super set of name tuples, unless I'm missing something.
03:47 Yeah, I definitely think in the use case, a lot of places where name 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.
03:58 I think you can say use slots.
04:00 Is that possible?
04:01 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 really interesting impact as well, because that would probably use less memory than name 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.
04:17 Of course.
04:17 Give us that answer.
04:18 Yeah, it's a call to the audience, indeed.
04:21 Very, very cool.
04:22 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, like, 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:40 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:47 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, like, 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, because could you imagine the pressure?
05:04 But, yeah, it's supposed to officially come out in June, but it's kind of gone 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:17 Oh, I've fallen for this before.
05:19 I'm going to answer Excel.
05:21 Excel.
05:22 Is that actually, you know, I don't know.
05:23 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:32 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 some, 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:51 And I think we maybe talked about this a little bit before in a couple shows back, but one of the listeners sent in this thing, this series from Carnegie Mellon University called the Databasology Lectures.
06:05 So there's a bunch of databases covered there, and there are actually quite a few interesting ones.
06:10 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.
06:31 So they have, like, the guy.
06:32 That sounds like an exciting date night.
06:35 Oh, yeah.
06:36 Yeah, my wife was pretty excited when I suggested that.
06:38 No.
06:38 So there's WiredTiger, which became the foundation of the storage engine of MongoDB.
06:44 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 tradeoffs 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 tradeoffs 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.
07:18 Something to do with Berkeley DB in there as well.
07:19 So, yeah, it's quite cool.
07:21 Yeah, but there's just so much I'm not really sure I want to try to cover it.
07:25 But if you want to look inside of, like, how do the B-trees map to 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?
07:51 I don't know, like, some insane number of lines.
07:53 They don't develop it as a single.
07:55 No.
07:56 No, there's some process, some mechanism that, like, detangles all the, you know, include statements and the various compile orders and all of that stuff.
08:08 And it, like, generates this one huge file with, like, no dependencies.
08:11 But it's pretty wild to think of such a program as created that way.
08:15 It's interesting that it's intentionally no dependencies.
08:18 The whole thing is a little bit unusual.
08:21 The way that the guy has created it and run it.
08:24 Like, instead of, he was like, well, open source is good.
08:27 But actually, I just want to make it like nobody.
08:30 This is a thing that just is the world.
08:33 And so he made it, put it out there under common domain or what's that called?
08:38 Anyway.
08:38 Where you just say, like, it belongs to the world.
08:40 I relinquish all ownership of this thing.
08:42 It is just now public domain.
08:44 Public domain.
08:45 Yeah.
08:46 So it's pretty interesting.
08:47 Yeah, it is.
08:47 Do you know what else is interesting?
08:49 Testing your code before you take down the system?
08:51 Or you charge a credit card and you didn't want to?
08:54 Yeah.
08:55 Did we get this from a listener?
08:57 I can't remember.
08:58 Yeah, this definitely came from a listener.
08:59 I can't remember who.
09:01 Maybe I'll pull that up while you're having a look.
09:04 Okay.
09:04 Well, this is a project called Dryable.
09:08 A useful dry run decorator for Python.
09:12 And the idea is that there's some times where you want to run your entire application, but there's pieces of it that you don't want to run all the time.
09:21 Like in their example, they've got, if you're accessing an outside database with requests 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 Basically, you put a decorator, it's a dryable decorator you put on top of a function.
09:42 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, you can specify that there.
10:07 And for testing certain systems, I think this is an awesome idea.
10:13 And it's pretty cool.
10:14 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, like what would that look like?
10:27 It looks like this dryable 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.
10:40 In your test code, you just say dryable.set true.
10:44 And then it just goes in the hood.
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.
10:51 But one of the things that I was wondering is like, we have mocking stuff.
10:57 And these other mechanisms for stubbing out stuff.
10:59 Like, where do you see this fitting in versus not?
11:04 A lot of times people, and I agree, mocking and monkey patching is often used 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 back end.
11:38 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:48 Yeah, okay.
11:49 That's pretty cool.
11:50 So I told you about DigitalOcean at the top of the show.
11:53 And I'll give you a little more details.
11:55 They actually have some super exciting news.
11:58 Maybe a week, week and a half ago, two weeks ago, I can't remember.
12:01 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?
12:08 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.
12:17 All right, now you get two gigs of RAM.
12:19 You have one CPU and you're paying a certain amount.
12:22 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,
12:31 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:45 Yeah, exactly.
12:47 So anyway, it's really cool that the new pricing that they put out.
12:52 So definitely drop over do.co slash Python and check that out.
12:56 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:01 Yeah.
13:01 So really nice.
13:02 And Python Bytes now delivers itself just a tiny bit faster and has, you know, a few more gigs of RAM to do it with.
13:09 Well, that's good because our listeners are going up.
13:12 Right.
13:12 We got to keep up with the demand.
13:13 Thank you, everyone.
13:15 Speaking of demand, we got actually a lot of listener feedback for the 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:24 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.
13:31 And then people told us.
13:33 Yeah.
13:33 And I still mostly stand by that.
13:37 But there are people doing really cool things.
13:39 And I just want to highlight them.
13:42 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.
13:48 You know, he was doing something else, but he needed to do some program to build this thing.
13:51 Right.
13:51 But I disagree with that.
13:53 Steve, 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.
14:01 And I don't know.
14:02 Do you click those and pull them up, Brian?
14:04 See the pictures?
14:04 I'm trying to pull up one now.
14:06 Yeah.
14:06 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,
14:13 screenshots.
14:13 Yes.
14:14 Pictures, please.
14:15 Just describing how awesome it is in text doesn't actually make it awesome.
14:19 But these look like rich, interesting applications.
14:23 And I definitely think what he's doing here is quite neat, especially the first and the
14:29 second one that we've linked.
14:30 So he linked to three.
14:31 This is crazy.
14:32 PT Tracking is both.
14:33 It's got both the desktop application, which looks nice.
14:36 And an iPhone version.
14:37 And an iPhone version.
14:38 Yeah, it's pretty interesting.
14:41 I mean, like I said, this guy built some really powerful stuff, right?
14:45 Yeah.
14:45 Looks great.
14:46 What's even better is it's open source, right?
14:48 This is TK Enter code.
14:50 And he's like, look, you're giving TK Enter a bad rap.
14:53 This is actually could be more nice looking if it's built the right way.
14:57 And by the way, here's three open source apps I built that you can check out with screenshots,
15:02 by the way, which is very nice.
15:04 So I just want to highlight that.
15:06 Say thank you, Victor, for sending these in.
15:07 Share the links he sent because they are pretty inspiring.
15:10 And they're working examples.
15:12 I did not know you could make an iPhone app with TK Enter.
15:15 I still don't even know how that works.
15:17 I don't either.
15:17 Maybe I'll try this out.
15:18 Maybe there's some kind of PEP for it.
15:20 Like a pep.
15:21 What is that?
15:22 Pep 7.225.
15:24 Make Python build desktop or mobile apps on iPhone.
15:28 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.
15:33 And it is by Anthony again.
15:37 Anthony Shah that we gave him credit on the first article that we talked about.
15:41 But Pep Explorer.
15:43 Explore Python enhancements with a web interface.
15:47 It's got a search function.
15:49 And you can look at all sorts of stuff.
15:51 There's even in the status.
15:52 I don't quite get all the status ones.
15:54 But there's an April Fool 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 It probably just scared people, actually.
16:04 That's really what happened.
16:05 Yeah.
16:05 So not only do you find the peps that were accepted, but you can search and say, show me
16:09 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:15 Yeah.
16:16 And then the ones that are still in draft form and everything.
16:19 One of the things I want to...
16:21 I had already picked this, and then I was playing with it.
16:23 Because the data classes that we talked about earlier, I cannot find on this little cool
16:30 tool here.
16:31 So I'm not sure what's going on with the 3.7 stuff.
16:34 Maybe 3.7 just isn't in here yet.
16:36 Yeah, maybe.
16:37 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.
16:45 So nice people do fix it and do a PR.
16:48 I just am going to call them out on Python bytes and say it's broken.
16:53 This one doesn't work.
16:54 It's not there.
16:55 And I can't do a PR right now because I'm recording a podcast.
16:57 Yeah, definitely.
16:58 Yeah.
16:59 Yeah.
16:59 Nice work, Anthony.
17:00 You know, enough to get a double feature.
17:02 Very, very cool.
17:03 So I want to round this out with just a little bit more UI stuff.
17:07 If I'm going to show you all those pictures of cool apps that Victor built, the other thing
17:12 I want to sort of pair with that is a TK Enter tutorial from this.
17:16 We got on Twitter as well from at like geeks.
17:20 And it's basically here's how you go through TK Enter and create your first GUI application.
17:23 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
17:32 what that looks like.
17:32 Right.
17:33 It's still like a decent distance from what Victor had built.
17:36 But if you are inspired by topic four, maybe topic six can help you take some steps in
17:41 that direction.
17:42 Yeah.
17:42 Okay.
17:43 Yeah.
17:43 It's pretty, 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, may be the final thing we say about it, or maybe my own news actually will cover
17:55 one more GUI thing.
17:56 Yeah.
17:56 I think that we have, we'll probably hear some more GUI things coming up in the future.
18:00 Yeah.
18:01 Yeah.
18:01 I'm okay with that.
18:02 I am too.
18:02 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
18:07 about this is WX Python.
18:09 Yeah.
18:09 What I didn't realize is WX Python has a project called WX Python Phoenix, where it was reborn
18:15 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.
18:24 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, dude, how about you?
18:29 Any other personal news you got going on?
18:32 Anything cool?
18:32 Not right now.
18:33 Nice.
18:34 For me, this is like the week of the recording, the recording.
18:38 So I'm recording six podcasts, talk Python, Python bytes.
18:43 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:55 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 make it act real.
19:02 It took like 15 minutes for the program to actually generate the database, but that was okay.
19:06 It was still good.
19:08 Anyway, so that was fun.
19:10 I'll put a link in there.
19:10 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?
19:18 And I'm like, oh, this is a cool little CLI.
19:20 But do you know what would be better is if it was a GUI.
19:24 It's like, yeah, I know.
19:25 You can't do that in Python, Kane.
19:26 You're like, yeah.
19:27 Hold on.
19:28 Like, let's pip install GUI, G-O-O-E-Y, the thing we already talked about.
19:31 And that thing is slick.
19:33 Let me tell you.
19:34 Basically, you create one of these argument parser things from GUI.
19:38 You say it takes these parameters and then you say get the parameters.
19:41 And that actually shows the UI with all the widgets filled out and the names and the types.
19:46 Like this one is a combo box.
19:47 It has these three items.
19:48 Like that's your argument.
19:49 Then it becomes just a combo box.
19:50 It really is like just a few lines of code.
19:52 It's awesome.
19:53 We've been getting a lot of people that have been using GUI show us their screenshots of
19:57 something they made with it in just a few minutes.
19:59 And that's pretty awesome.
20:00 I really think the bang for the buck is quite high on GUI right now.
20:04 And that's WX Python, by the way.
20:05 Also, a quick announcement on the courses.
20:09 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:13 But I just launched a sort of business option team purchase page.
20:19 All the bundles and the courses and stuff at Talk Python Training.
20:23 Now have a buy this for your team.
20:24 And if you pick like 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 want to 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.
20:36 So trying to make it easy for people to get more of that Python knowledge.
20:40 Yeah.
20:40 All right.
20:42 Well, thanks, Brian, for finding all these things and sharing with me.
20:44 Yeah.
20:45 Thank you.
20:45 Yeah.
20:45 Bye.
20:47 Thank you for listening to Python Bytes.
20:49 Follow the show on Twitter via at Python Bytes.
20:51 That's Python Bytes as in B-Y-T-E-S.
20:54 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.