WEBVTT

00:00:00.001 --> 00:00:05.500
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:00:05.500 --> 00:00:10.780
This is episode 88, recorded July 26, 2018. I'm Michael Kennedy.

00:00:10.780 --> 00:00:11.620
And I'm Brian Okken.

00:00:11.620 --> 00:00:12.440
Brian, how are you doing?

00:00:12.440 --> 00:00:13.200
I'm doing great.

00:00:13.200 --> 00:00:18.240
Yeah, it's a ton of good stuff that I think you found this week, and I'm looking forward to share what I got as well.

00:00:18.240 --> 00:00:20.580
It's never a boring week in the Python world, is it?

00:00:20.580 --> 00:00:21.400
No, it isn't.

00:00:21.400 --> 00:00:27.260
No. Well, it's definitely not boring if your app has problems. You need to track them down.

00:00:27.260 --> 00:00:33.040
So if you're in that space, you might want to check out Datadog over at pythonbytes.fm/Datadog.

00:00:33.040 --> 00:00:35.200
Tell you more about them later.

00:00:35.200 --> 00:00:37.980
Right now, I want to know about documenting code.

00:00:37.980 --> 00:00:45.700
We do hear a lot about, I think we hear a lot about making sure that your code documentation is good.

00:00:45.700 --> 00:00:50.720
There's the read the docs and make the docs effort, or I guess it's write the docs.

00:00:50.720 --> 00:00:52.740
And there's quite a bit of that.

00:00:52.740 --> 00:00:57.040
And I think a lot of that is focused on the end user user documentation.

00:00:57.040 --> 00:00:58.600
And that's definitely important.

00:00:58.600 --> 00:01:06.080
But there's an article on, I think it was on RealPython, called Documenting Python Code, A Complete Guide.

00:01:06.080 --> 00:01:10.820
It's an article that describes really why you should comment and document your code.

00:01:10.820 --> 00:01:16.680
It talks about the differences between comments and doc strings and different separate documentation.

00:01:17.160 --> 00:01:21.820
But one of the things that I want to zoom in on is the code comments.

00:01:21.820 --> 00:01:29.160
And I don't think very many people get really how, if they think about their comments that they put in their code, how effective they can be.

00:01:29.160 --> 00:01:33.920
So I want to kind of zoom in on some of the things that they cover in this article on code comments.

00:01:34.440 --> 00:01:37.860
So code comments are those things that start with a pound sign or hash.

00:01:37.860 --> 00:01:41.120
And they're not really part of your runtime.

00:01:41.120 --> 00:01:43.160
You can't get a hold of them at runtime.

00:01:43.160 --> 00:01:47.340
They're intended for you and other maintainers and other developers of the code.

00:01:48.120 --> 00:01:57.800
And some of the things that I've used them for, but I never really saw anybody point out before, is before you even start your code, you can use comments to plan what you're going to write.

00:01:57.800 --> 00:02:04.940
And you can also, once you've written your code, review to make sure the code really matches what you planned to do.

00:02:04.940 --> 00:02:11.660
And then sometimes those kind of comments are best to be, if your code is clear enough, just go ahead and delete those when you're done.

00:02:11.780 --> 00:02:12.240
I like that.

00:02:12.240 --> 00:02:13.540
I end up doing that a lot myself.

00:02:13.540 --> 00:02:15.480
I'm like, okay, I'm not entirely sure how to do this.

00:02:15.480 --> 00:02:17.020
So I'll sketch this out in comments.

00:02:17.020 --> 00:02:19.000
Like, here's the five steps I think I got to do.

00:02:19.000 --> 00:02:20.860
And then I'll just take them one at a time.

00:02:20.860 --> 00:02:22.620
And then I always delete those comments.

00:02:22.620 --> 00:02:23.360
Almost always.

00:02:23.360 --> 00:02:23.880
Yeah.

00:02:23.880 --> 00:02:32.760
The deleting part is important because if you don't do that, then you get the common pitfall of a code comment that says, retrieve web page.

00:02:32.760 --> 00:02:36.160
And then the very next line is one line of code that's a request or something.

00:02:36.160 --> 00:02:36.780
And it's obvious.

00:02:37.180 --> 00:02:44.720
If it's not obvious, using those to explain intent, don't explain really how it's done, but explain why you're doing it.

00:02:44.720 --> 00:02:51.340
And then sometimes you'll have like a complicated math algorithm or something that's fairly terse if you need to explain that better.

00:02:51.340 --> 00:02:59.260
But we're trying to get as few comments as possible, minimizing those because you want to make your code pretty clear to begin with.

00:02:59.260 --> 00:03:04.840
But one of the other things that I think is I've just started using quite a bit is the to-do feature.

00:03:04.980 --> 00:03:10.420
So using code comments to the article mentions to-do, bug, and fix me type sections.

00:03:10.420 --> 00:03:13.920
Hopefully you're not putting too many bugs and fix me's in your code.

00:03:13.920 --> 00:03:25.560
But to-dos are, I think those are great for, because when we're in the middle of coding, it's often easy to get caught up in, well, I could make it more powerful if I added these other features.

00:03:25.560 --> 00:03:27.820
Just go ahead and like write that as a comment.

00:03:27.980 --> 00:03:32.500
You don't really need to fall into the trap of making your code do too much at once.

00:03:32.500 --> 00:03:39.640
And then the article also has some other tips on best practices for how to format your code comments and stuff.

00:03:39.640 --> 00:03:44.120
Of course, it goes on and talks about doc strings and how to utilize those.

00:03:44.120 --> 00:03:48.560
Also using type hints for commenting and documentation.

00:03:48.560 --> 00:03:55.980
And then goes on to do like the larger, talks about the larger types of project documentation, like using Sphinx and make docs and stuff.

00:03:55.980 --> 00:03:56.240
Yeah.

00:03:56.240 --> 00:03:58.540
It's a really great article and it is really in-depth.

00:03:58.540 --> 00:04:01.280
I always learn something from the real Python articles.

00:04:01.280 --> 00:04:01.900
It's cool.

00:04:01.900 --> 00:04:08.160
You know, one thing about the to-do stuff that I use a lot and I really like is the editor integration.

00:04:08.720 --> 00:04:10.460
So I can't speak to the other ones.

00:04:10.460 --> 00:04:13.060
I don't really know how exactly they handle it.

00:04:13.060 --> 00:04:19.880
But it's saying PyCharm, if you have hash to do colon something, there's a special pane where you can say, show me all the to-dos in this project.

00:04:19.880 --> 00:04:24.540
And even when you try to commit, like, you know, I want to commit this stuff to GitHub.

00:04:24.540 --> 00:04:27.740
It'll say, warning, there's three to-dos in here.

00:04:27.740 --> 00:04:30.660
Are you sure you want to commit to GitHub with these three to-dos?

00:04:30.660 --> 00:04:33.600
And then I think it actually even remembers those three.

00:04:33.600 --> 00:04:38.200
But if you had another one, it'll say, oh, there's like a new to-do you haven't like approved to commit, things like that.

00:04:38.200 --> 00:04:39.100
So it's pretty sweet.

00:04:39.100 --> 00:04:39.440
Yeah.

00:04:39.440 --> 00:04:43.300
I actually, I stumbled across that feature without knowing it was there.

00:04:43.300 --> 00:04:45.080
And I'm like, oh, man, this is great.

00:04:45.080 --> 00:04:46.240
So I like it.

00:04:46.240 --> 00:04:46.460
Yeah.

00:04:46.460 --> 00:04:47.000
It's cool.

00:04:47.000 --> 00:04:49.260
Even colors the comment different if it's a to-do comment.

00:04:49.260 --> 00:04:51.180
So people should definitely do that.

00:04:51.180 --> 00:04:57.200
So we talked a while ago about security vulnerabilities and other types of alerts.

00:04:57.200 --> 00:05:07.340
And we even covered how GitHub has this, like, dependency thing where you can see the dependencies, but it didn't cover Python, which was unfortunate, right?

00:05:07.340 --> 00:05:07.740
Right.

00:05:07.740 --> 00:05:09.160
Well, big news.

00:05:09.160 --> 00:05:10.320
It now supports Python.

00:05:10.320 --> 00:05:11.460
That was pretty fast.

00:05:11.460 --> 00:05:12.340
That was.

00:05:12.340 --> 00:05:13.300
They got on that pretty quick.

00:05:13.300 --> 00:05:13.840
They did.

00:05:13.840 --> 00:05:15.240
So it's pretty sweet.

00:05:15.240 --> 00:05:22.080
If you go to any GitHub repository and you go to insights, and then there's a bunch of options on the left, you pick dependency graph.

00:05:22.320 --> 00:05:25.120
It will actually show you all of the files.

00:05:25.120 --> 00:05:32.240
It's either found in a pip file.lock or in a requirements.txt anywhere in the project.

00:05:32.240 --> 00:05:32.600
Wow.

00:05:32.600 --> 00:05:33.060
That's cool.

00:05:33.060 --> 00:05:33.920
And it'll list them out.

00:05:33.920 --> 00:05:35.660
And it'll say it's pinned to this version.

00:05:35.820 --> 00:05:41.340
But warning, this version actually has a security vulnerability and is fixed by this other release of it.

00:05:41.340 --> 00:05:50.100
So if I'm using, say, Pyramid and there happened to have been, like, a security vulnerability in that, it would let me know and it would, like, actually highlight that and give me an alert.

00:05:50.100 --> 00:05:50.680
Okay.

00:05:50.680 --> 00:05:51.220
Neat.

00:05:51.220 --> 00:05:51.620
Yeah.

00:05:51.620 --> 00:05:52.460
It's really cool.

00:05:52.580 --> 00:05:56.980
So it had previously only worked with Ruby and JavaScript, but now they just announced it.

00:05:56.980 --> 00:06:03.500
They said for the Ruby and JavaScript people, they've identified millions of vulnerabilities and prompted many patches, which is pretty cool.

00:06:03.500 --> 00:06:03.880
Okay.

00:06:03.880 --> 00:06:07.000
I'm just checking my cards project to make sure it's clean.

00:06:07.000 --> 00:06:07.960
It looks like it's good.

00:06:07.960 --> 00:06:08.380
Yeah.

00:06:08.380 --> 00:06:08.860
And it's interesting.

00:06:08.860 --> 00:06:11.880
You can actually, it's like a tree structure that you get to.

00:06:11.880 --> 00:06:16.460
So you can go there and it'll say, suppose you're using requests, for example, right?

00:06:16.620 --> 00:06:25.480
Then there's, like, a little Chevron expando thing by requests and it'll open up and say, well, this depends on six and char dead or, you know, whatever it depends upon.

00:06:25.480 --> 00:06:35.200
I can't remember the exact dependency of requests, but you can actually expand it out and see, like, the transitive closure or, like, what your dependencies, dependencies, dependencies depend upon.

00:06:35.200 --> 00:06:40.420
And, like, if there's a vulnerability deep, deep down that you didn't directly install but effectively you installed.

00:06:40.420 --> 00:06:41.360
So it's really nice.

00:06:41.360 --> 00:06:43.040
The dependency graph is cool.

00:06:43.180 --> 00:06:48.060
It even has, it'll even follow a requirements underscore dev.

00:06:48.060 --> 00:06:48.340
Yeah.

00:06:48.340 --> 00:06:49.140
It'll get all of them.

00:06:49.140 --> 00:06:49.340
Yeah.

00:06:49.340 --> 00:06:51.460
And then you can also look at dependents.

00:06:51.460 --> 00:06:53.540
So people depending on your project.

00:06:53.540 --> 00:06:54.220
Interesting.

00:06:54.220 --> 00:06:55.020
Right.

00:06:55.020 --> 00:06:55.280
Right.

00:06:55.280 --> 00:06:58.740
So if you've got, like, a public package, you can see what depends upon it.

00:06:58.740 --> 00:07:02.220
I wonder if you go to request if that breaks the UI.

00:07:02.220 --> 00:07:05.960
Yeah.

00:07:05.960 --> 00:07:10.100
I'll leave that exercise to the reader because I don't want my web browser to fail.

00:07:10.100 --> 00:07:10.700
Yeah.

00:07:10.700 --> 00:07:11.220
Exactly.

00:07:11.220 --> 00:07:11.780
Exactly.

00:07:12.260 --> 00:07:17.060
Anyway, so we've seen other services like pyup.io, which I use and still recommend.

00:07:17.060 --> 00:07:23.700
But this is a nice way to just, like, walk up to a public GitHub repository and say, well, what are its dependencies?

00:07:23.700 --> 00:07:24.820
Is it up to date?

00:07:24.820 --> 00:07:27.840
Things like that without actually using it or registering it.

00:07:27.840 --> 00:07:28.080
It's cool.

00:07:28.080 --> 00:07:28.500
Right.

00:07:28.500 --> 00:07:32.640
So pyup, you would have to have it be on your own and you could do that.

00:07:32.640 --> 00:07:36.660
But this allows you to look at that for any project on GitHub.

00:07:36.660 --> 00:07:37.100
Right.

00:07:37.100 --> 00:07:37.500
Exactly.

00:07:37.500 --> 00:07:41.640
Does maybe this project have a security vulnerability in its dependency or not?

00:07:41.640 --> 00:07:43.020
If it doesn't, then I'm going to use it.

00:07:43.020 --> 00:07:45.580
If it does, maybe I'll wait or do a PR or something.

00:07:45.580 --> 00:07:45.980
Yeah.

00:07:45.980 --> 00:07:46.840
Nice.

00:07:46.840 --> 00:07:51.980
Well, speaking of dependencies, I depend on pip a lot and virtual environments.

00:07:52.320 --> 00:07:52.560
Yes.

00:07:52.560 --> 00:07:53.300
All the time.

00:07:53.300 --> 00:07:58.440
I try to, like, super optimize what I do in the command line around pip and virtual environments.

00:07:58.440 --> 00:08:07.400
So much so that I have a single alias that will create a virtual environment, make sure pip and setup tools is up to date, and then activate it all in, like, a couple of characters.

00:08:07.400 --> 00:08:08.020
I love it.

00:08:08.120 --> 00:08:08.700
Yeah, nice.

00:08:08.700 --> 00:08:10.880
So the virtual environments are so useful.

00:08:10.880 --> 00:08:17.680
I was happy to see this article pop up that's called How Virtual Environment Libraries Work in Python.

00:08:17.680 --> 00:08:20.020
And I'm just going to quote it.

00:08:20.020 --> 00:08:24.800
It says, have you ever wondered what happens when you activate a virtual environment and how it works internally?

00:08:25.360 --> 00:08:34.040
Here's a quick overview of the internals behind popular virtual environments, for example, virtualenv, virtualenv,wrapper,conda, and pipenv.

00:08:34.040 --> 00:08:39.500
And, yeah, it's a really fairly quick look at how there's really not much.

00:08:39.500 --> 00:08:40.540
I didn't know this.

00:08:40.540 --> 00:08:46.120
So one of the things that it points out is that all of these sort of work on a little bit of a hack.

00:08:46.360 --> 00:08:53.720
And these hacks are based on the fact that when the Python interpreter starts, when the interpreter starts, it searches.

00:08:53.720 --> 00:09:00.300
It's trying to find a site-specific directory to find all the modules it can import and all the packages.

00:09:00.300 --> 00:09:12.040
And so the search starts with the parent directory of the Python executable location and then continues backtracking up the path into parent directories until it reaches all the way to the root.

00:09:12.240 --> 00:09:17.040
But it's also looking for a lib directory with os.py in it.

00:09:17.040 --> 00:09:19.560
Apparently, it's looking for that magic module.

00:09:19.560 --> 00:09:24.400
And then if it finds that, that's the local site packages directory.

00:09:24.400 --> 00:09:33.520
So the hack is to let it copy the executable somewhere and then create a directory with that symbolically linked.

00:09:33.520 --> 00:09:36.520
And then you can have other stuff symbolically linked inside, too.

00:09:36.520 --> 00:09:42.080
And earlier versions wouldn't symbolically link everything in the site packages if you had everything.

00:09:42.080 --> 00:09:44.160
Or a whole bunch of stuff, at least.

00:09:44.160 --> 00:09:45.120
I'm not sure if it's everything.

00:09:45.120 --> 00:09:54.940
In Python 3.3, it came up with a couple of tricks with a pyvnv config file that allows you to not have to copy the executable completely.

00:09:54.940 --> 00:09:55.700
You can copy.

00:09:55.700 --> 00:09:58.180
You can have a symbolic link to the executable.

00:09:58.180 --> 00:10:01.220
And all of this is how the sausage is made.

00:10:01.380 --> 00:10:06.520
But I found it fairly interesting to figure out how all these virtual environment things work.

00:10:06.520 --> 00:10:08.200
Yeah, I think this is really helpful.

00:10:08.200 --> 00:10:14.580
Because certainly being effective with Python is being effective managing your dependencies and stuff.

00:10:14.580 --> 00:10:16.560
And the way you do that is virtual environments.

00:10:16.560 --> 00:10:19.160
So this is a really good look at how that works.

00:10:19.440 --> 00:10:24.200
Yeah, and to me, it did seem like after about 3.3, that things sort of went faster.

00:10:24.200 --> 00:10:29.900
And now it makes sense that it's faster because they're not copying the executable into a new location.

00:10:29.900 --> 00:10:32.120
So it's a clean look.

00:10:32.120 --> 00:10:33.340
And I'm with you.

00:10:33.520 --> 00:10:37.080
I've tried a whole bunch of off-the-shelf helper things.

00:10:37.080 --> 00:10:47.540
And it's just my own handful of commands that I've come up with that I've just stuck them in my bash config file as little functions.

00:10:47.540 --> 00:10:48.800
Because they don't do much.

00:10:48.800 --> 00:10:51.600
I just needed to create a virtual environment and then activate it.

00:10:51.600 --> 00:10:53.720
And then, like you said, update pip.

00:10:53.720 --> 00:10:55.000
And what else do you update?

00:10:55.000 --> 00:10:55.760
Set up tools.

00:10:55.760 --> 00:10:56.260
Okay.

00:10:56.260 --> 00:10:56.680
Yeah.

00:10:56.680 --> 00:10:57.400
It's interesting.

00:10:57.400 --> 00:10:59.820
There's a lot of things that try to help and manage this stuff.

00:10:59.820 --> 00:11:01.240
And they're all pretty good.

00:11:01.720 --> 00:11:07.020
But in reality, like you say, I just want to run these three commands and just get rolling and just keep it simple.

00:11:07.020 --> 00:11:15.540
And I could just create that as an alias and like a bash RC or a ZSHRC and separate the three commands with a double ampersand.

00:11:15.540 --> 00:11:16.900
And then, boom, it's one command.

00:11:16.900 --> 00:11:17.320
You're good.

00:11:17.320 --> 00:11:23.160
And for people like us that are doing a lot of like trying out a lot of new things, I create a lot of virtual environments.

00:11:23.160 --> 00:11:37.960
I do agree with Kenneth Reitz and the others that are promoting pip.env that for because of all of the hashes and security reasons, for full application development, I think using pip.env is the right thing.

00:11:37.960 --> 00:11:39.860
And keeps everybody in the project.

00:11:39.860 --> 00:11:41.400
We're using the project on the same page.

00:11:41.940 --> 00:11:47.040
But there's plenty of other uses for raw virtual environment or V and V that I use.

00:11:47.040 --> 00:11:47.300
Yeah.

00:11:47.300 --> 00:11:47.720
Pretty interesting.

00:11:47.720 --> 00:11:53.380
One final little tidbit of news that I don't think justifies its own place.

00:11:53.380 --> 00:11:57.460
But pip, not too long ago, went from version 9 to version 10, right?

00:11:57.460 --> 00:11:58.140
Oh, yeah.

00:11:58.140 --> 00:11:58.640
Yeah.

00:11:58.640 --> 00:11:59.680
I'm glad you brought that up.

00:11:59.680 --> 00:12:00.240
That's big.

00:12:00.240 --> 00:12:03.280
So now, in the last week or two, I haven't really been paying attention.

00:12:03.280 --> 00:12:04.820
But it went from 10 to 18.

00:12:04.820 --> 00:12:05.280
Yeah.

00:12:05.280 --> 00:12:07.260
It completely skipped.

00:12:07.260 --> 00:12:09.140
A lot of features.

00:12:09.140 --> 00:12:13.400
But it switched from whatever that normal versioning.

00:12:13.400 --> 00:12:14.240
Semantic versioning.

00:12:14.240 --> 00:12:16.660
Semantic versioning to date-based versioning.

00:12:16.660 --> 00:12:16.940
Yes.

00:12:16.940 --> 00:12:19.320
So I don't understand how the date works.

00:12:19.320 --> 00:12:22.280
Maybe it's the year, but surely there's more than one release in a year.

00:12:22.280 --> 00:12:22.680
Who knows?

00:12:22.680 --> 00:12:24.100
Anyway, it's pretty cool.

00:12:24.100 --> 00:12:24.940
Maybe it is 2018.

00:12:24.940 --> 00:12:28.280
But yeah, so there's a brand new version of pip, a new versioning scheme there.

00:12:28.280 --> 00:12:28.540
Yeah.

00:12:28.540 --> 00:12:29.080
Cool.

00:12:29.080 --> 00:12:29.380
Nice.

00:12:29.960 --> 00:12:30.260
All right.

00:12:30.260 --> 00:12:33.320
Before we get to the next one, let me tell you about Datadog, our sponsor.

00:12:33.320 --> 00:12:39.760
So if you have infrastructure and you want to monitor it, you want to trace a request,

00:12:39.760 --> 00:12:45.600
say, across your web tier to some microservice series of services down at the database,

00:12:45.600 --> 00:12:51.120
put the logs all together that Datadog provides end-to-end visibility for the health and performance

00:12:51.120 --> 00:12:52.380
of your Python apps.

00:12:52.380 --> 00:12:56.720
You can explore metrics, distribute request traces and logs, all that in one place.

00:12:56.720 --> 00:12:58.820
And even have a 14-day free trial.

00:12:58.820 --> 00:13:03.760
And if you check them out at pythonbytes.fm/Datadog, set up a trial, you get a sweet,

00:13:03.760 --> 00:13:05.100
cute Datadog t-shirt.

00:13:05.100 --> 00:13:06.600
So that makes it worth it right there.

00:13:06.600 --> 00:13:07.040
Yeah.

00:13:07.040 --> 00:13:08.320
So anyway, check them out.

00:13:08.320 --> 00:13:09.440
It really helps support the show.

00:13:09.440 --> 00:13:11.500
Brian, have we talked about GUIs?

00:13:12.660 --> 00:13:13.660
Yes, I think so.

00:13:13.660 --> 00:13:14.300
Maybe.

00:13:14.300 --> 00:13:14.340
Maybe.

00:13:14.340 --> 00:13:14.540
Maybe.

00:13:14.540 --> 00:13:15.280
Maybe.

00:13:15.280 --> 00:13:23.420
So one of the really nice things about having TK Enter built in to Python is it's really easy.

00:13:23.420 --> 00:13:24.300
It just comes along.

00:13:24.300 --> 00:13:25.380
You don't have to do stuff.

00:13:25.880 --> 00:13:31.840
previously to use something like Qt or I think the same may be true for wxPython.

00:13:31.840 --> 00:13:36.480
But for Qt, it was a serious pain to get that installed so that you could use it.

00:13:36.480 --> 00:13:40.200
It's like, well, you run this funky package on Ubuntu.

00:13:40.200 --> 00:13:42.520
You download this installer for Mac.

00:13:42.560 --> 00:13:46.700
And then all of a sudden, you're like, here's my simple Python file that's going to be your app

00:13:46.700 --> 00:13:52.460
becomes like this weird extra dependency installing problem, right?

00:13:52.460 --> 00:13:59.120
So the Qt company, the people that make Qt, the framework, and then they've taken over PySide2,

00:13:59.120 --> 00:14:01.720
the wrapper, and they've rebranded it for Qt for Python.

00:14:01.720 --> 00:14:04.680
Well, they've made that much, much easier.

00:14:04.680 --> 00:14:12.220
So now if I have an application and it has like a requirements file or a pip file.lock or whatever,

00:14:12.400 --> 00:14:19.820
pip file that says, I depend upon PySide2, which is the working package name for Qt for Python right now.

00:14:19.820 --> 00:14:25.240
If you depend upon that, all you have to do is pip install requirements and you have it

00:14:25.240 --> 00:14:27.640
because it ships as a wheel right off PyPy.

00:14:27.640 --> 00:14:27.960
Okay.

00:14:27.960 --> 00:14:29.080
Nice.

00:14:29.080 --> 00:14:34.180
If you want to use Qt, instead of having like really painful dependencies that people have to set up

00:14:34.180 --> 00:14:38.280
and like a little step, you want to run our app, well, click here to go to this page to set up Qt.

00:14:38.280 --> 00:14:40.180
Now you just pip install your requirements.

00:14:40.180 --> 00:14:41.500
Boom, you have Qt.

00:14:41.500 --> 00:14:42.020
It's nice.

00:14:42.240 --> 00:14:42.760
That is nice.

00:14:42.760 --> 00:14:44.220
That's a huge thing, actually.

00:14:44.220 --> 00:14:46.600
I was considering, basically, I'm like, I'm not using Qt.

00:14:46.600 --> 00:14:51.900
What is required is this separate go find and install Qt so you can run my app.

00:14:51.900 --> 00:14:55.980
Like that just means there's no way that that's reasonable for distributing that to people.

00:14:55.980 --> 00:15:00.860
But if all you got to do is like package the dependencies, then, you know, presumably you

00:15:00.860 --> 00:15:03.740
could package it up with like PyInstaller at this point, maybe.

00:15:03.740 --> 00:15:05.160
So really nice.

00:15:05.500 --> 00:15:14.900
And I want to shout out to all of the people that every time we cover this contact me and tell me that I'm mispronouncing Qt as Qt.

00:15:14.900 --> 00:15:19.060
That this time it was Michael that pronounced it Qt instead of Qt.

00:15:19.280 --> 00:15:21.760
I think I had it right before, didn't I?

00:15:21.760 --> 00:15:22.400
Oh, well.

00:15:22.400 --> 00:15:24.000
Maybe you've infected me.

00:15:24.000 --> 00:15:25.820
No, it's, yeah, Qt for Python.

00:15:25.820 --> 00:15:26.600
Yeah, it's cool.

00:15:26.600 --> 00:15:26.840
Yeah.

00:15:26.840 --> 00:15:27.560
Well, I don't know.

00:15:27.560 --> 00:15:28.580
I think that's official.

00:15:28.580 --> 00:15:29.140
Yeah, yeah.

00:15:29.140 --> 00:15:29.700
I think so, too.

00:15:30.120 --> 00:15:34.980
And also for all the people that said, yes, you've covered 17 GUI frameworks, but have

00:15:34.980 --> 00:15:35.940
you heard of these other two?

00:15:35.940 --> 00:15:42.020
So that's, we're definitely learning a lot about the different frameworks out there.

00:15:42.020 --> 00:15:44.400
So this is one more advance there.

00:15:44.400 --> 00:15:48.820
I don't think people should stop because I still don't, I think this is great, but I don't

00:15:48.820 --> 00:15:49.900
think it's completely solved.

00:15:49.900 --> 00:15:52.200
So people keep trying to solve it with new libraries.

00:15:52.200 --> 00:15:52.760
Go for it.

00:15:52.760 --> 00:15:53.200
Absolutely.

00:15:53.200 --> 00:15:53.720
Absolutely.

00:15:53.720 --> 00:15:54.280
All right.

00:15:54.280 --> 00:15:56.300
What's this next one you got about exceptions here, Brian?

00:15:56.300 --> 00:15:56.780
Okay.

00:15:56.860 --> 00:16:03.760
Well, so exceptions, I think if, and I misspelled it, but exceptions are part of Python.

00:16:03.760 --> 00:16:10.700
And even if they're kind of, I think they're handled sort of later when you're learning about

00:16:10.700 --> 00:16:15.180
how to program in Python, you sort of deal with telling people how to use exceptions later,

00:16:15.180 --> 00:16:20.760
but you're going to have to deal with them because whether or not you write your own exceptions

00:16:20.760 --> 00:16:27.620
or utilize, raise, and try accept yourself, other, your libraries that you utilize are

00:16:27.620 --> 00:16:29.220
utilizing or using it.

00:16:29.220 --> 00:16:32.600
So if you don't want your program to crash, you got to figure out how to do all this.

00:16:32.600 --> 00:16:38.640
So this is, not only is it a tutorial on how to use exceptions, it's learning how not to

00:16:38.640 --> 00:16:43.540
handle exceptions because sometimes the right thing to do is not to catch an exception.

00:16:43.700 --> 00:16:49.500
The right thing to do is to pass it, either ignore it completely because it'll pass up to a higher

00:16:49.500 --> 00:16:49.900
level.

00:16:49.900 --> 00:16:55.040
And that's part of one of the, one of the things that's this, in this article, an article called

00:16:55.040 --> 00:17:00.320
learning not to handle exceptions, talks about not only how to use them, but how to not use them

00:17:00.320 --> 00:17:00.760
correctly.

00:17:00.760 --> 00:17:03.780
How do, so first it does tell you how to use them correctly.

00:17:03.780 --> 00:17:05.700
Like the try and accept and raise.

00:17:05.920 --> 00:17:07.460
So try and accept are obvious.

00:17:07.460 --> 00:17:12.480
So if you try a bunch of, a bit of code, and then you can use an accept clause to catch something

00:17:12.480 --> 00:17:17.440
right off the bat, they tell you, which is, I think, correct, is usually you don't want to

00:17:17.440 --> 00:17:18.180
accept everything.

00:17:18.180 --> 00:17:21.960
You want to accept a specific exception that you know how to deal with.

00:17:21.960 --> 00:17:26.440
And then everything that you don't know how to deal with, just let it pass you up the stack.

00:17:26.440 --> 00:17:30.320
But sometimes even if you catch it, you want to keep raising it.

00:17:30.440 --> 00:17:35.540
So you can, it does talk about re-raising an exception with just raise without any keywords

00:17:35.540 --> 00:17:38.960
out or any, any exception after it'll just raise the current exception.

00:17:38.960 --> 00:17:39.240
Yeah.

00:17:39.240 --> 00:17:42.340
I really like that is like, you have a try, do your thing, accept.

00:17:42.340 --> 00:17:48.400
And then maybe you want to do some kind of compensating action, like roll back a transaction

00:17:48.400 --> 00:17:50.480
or delete a temporary file.

00:17:50.480 --> 00:17:52.440
But then you don't really want to handle it.

00:17:52.440 --> 00:17:57.060
You just needed to say, if there's a problem, I got to fix this and then let somebody else actually

00:17:57.060 --> 00:17:57.380
handle it.

00:17:57.380 --> 00:17:59.980
So then you just say raise, or you could even use the raise.

00:17:59.980 --> 00:18:03.380
One exception from another exception and chain them.

00:18:03.380 --> 00:18:03.760
Yeah.

00:18:03.760 --> 00:18:04.560
Yeah.

00:18:04.560 --> 00:18:04.880
It was really nice.

00:18:04.880 --> 00:18:07.400
And then there's other things like finally and else.

00:18:07.400 --> 00:18:12.240
So finally can allow you to run some code, whether or not an exception runs.

00:18:12.240 --> 00:18:16.380
And then else lets you run some code only if there are no exceptions.

00:18:16.380 --> 00:18:19.860
And you can use both of them at the same time with the same exception.

00:18:19.860 --> 00:18:20.260
Yeah.

00:18:20.260 --> 00:18:21.740
Both can be utilized.

00:18:21.740 --> 00:18:22.080
Yeah.

00:18:22.180 --> 00:18:27.240
The article goes on and covers dealing with tracebacks, custom exceptions, and then some

00:18:27.240 --> 00:18:32.600
best practices, and then making your exceptions more readable by adding arguments and printing

00:18:32.600 --> 00:18:34.300
things out nicely and stuff.

00:18:34.300 --> 00:18:35.800
So this is good.

00:18:35.800 --> 00:18:36.240
Yeah.

00:18:36.240 --> 00:18:37.180
It's really nice.

00:18:37.180 --> 00:18:38.060
Great little article.

00:18:38.060 --> 00:18:40.100
Definitely a nice find there.

00:18:40.960 --> 00:18:48.000
So I thought I'd put here at the end of our episode today something that takes a step back

00:18:48.000 --> 00:18:55.440
and just looks at the overall community, the ecosystem, and a bit of an interesting, I don't

00:18:55.440 --> 00:18:56.560
know, high-level view of Python.

00:18:57.020 --> 00:19:02.680
So last week we did our whole special episode on Guido von Rossum stepping down, right, with

00:19:02.680 --> 00:19:05.960
Brett Cannon, Carol Willing, and sort of covered that whole news.

00:19:05.960 --> 00:19:11.960
But another interesting thing that happened that is around that is, you know, sort of speaks

00:19:11.960 --> 00:19:16.940
to Python's popularity is, you know, the magazine, The Economist?

00:19:16.940 --> 00:19:17.940
Yeah, definitely.

00:19:17.940 --> 00:19:21.760
They did a feature in The Economist on Python and Guido von Rossum.

00:19:21.760 --> 00:19:24.280
That's pretty mainstream and huge.

00:19:24.280 --> 00:19:25.980
That's pretty interesting, right?

00:19:25.980 --> 00:19:26.460
Yeah.

00:19:26.580 --> 00:19:30.540
So there's an article in The Economist called Python Has Brought Computer Programming to

00:19:30.540 --> 00:19:33.200
a Vast New Audience, which is pretty awesome.

00:19:33.200 --> 00:19:39.680
And it covers like the meteoric growth of Python, how it's becoming so much more popular than

00:19:39.680 --> 00:19:43.040
many things, how, why, and where people are learning Python.

00:19:43.040 --> 00:19:44.740
So I thought that was all quite interesting.

00:19:44.740 --> 00:19:49.940
And then interspersed in there is sort of the history of Python with quotes from Guido himself.

00:19:49.940 --> 00:19:50.760
So it's pretty cool.

00:19:50.760 --> 00:19:52.940
Yeah, this is some nice publicity here.

00:19:52.940 --> 00:19:54.140
Yeah, not too shabby.

00:19:54.140 --> 00:19:56.560
And it's not a super long read.

00:19:56.560 --> 00:19:58.220
But it's a pretty nice treatment.

00:19:58.220 --> 00:20:02.760
It talks about some interesting things like some really powerful things that people are

00:20:02.760 --> 00:20:05.900
doing with Python, some interesting ways that people are learning it.

00:20:05.900 --> 00:20:11.240
But it also says, you know, there are some dangers to Python growing so fast as a lot of people

00:20:11.240 --> 00:20:16.660
are coming into the industry, learning just enough, grabbing something like TensorFlow, you

00:20:16.660 --> 00:20:22.060
know, some AI framework and sort of understanding it and then drawing conclusions from what the

00:20:22.060 --> 00:20:27.180
machine learning algorithms, they sort of understand, tell them, you know, and run off with like half

00:20:27.180 --> 00:20:27.820
baked ideas.

00:20:27.820 --> 00:20:29.720
I thought that was an interesting comment.

00:20:29.720 --> 00:20:30.240
Yeah.

00:20:30.380 --> 00:20:32.560
Well, I mean, yeah, that is an interesting comment.

00:20:32.560 --> 00:20:36.320
But half understanding what you're talking about and drawing conclusions.

00:20:36.320 --> 00:20:41.360
We see that every day with like statistics and in newspapers and stuff also.

00:20:41.360 --> 00:20:42.320
Yeah, absolutely.

00:20:42.540 --> 00:20:46.360
I mean, even in like medicine and medical research, that stuff is rampant.

00:20:46.360 --> 00:20:50.760
It's a lack of understanding of statistics is a problem across the board.

00:20:50.760 --> 00:20:51.940
I haven't read the article yet.

00:20:51.940 --> 00:20:53.460
I'm excited to read it.

00:20:53.540 --> 00:20:59.680
But the interesting things is people learning to code isn't necessarily because you're going

00:20:59.680 --> 00:21:01.580
to end up being a professional programmer.

00:21:01.580 --> 00:21:07.080
It's often one of the things that helps it grow is a lot of people using it as part of

00:21:07.080 --> 00:21:12.780
their other job, like a biologist or somebody else that is just using it to help out with

00:21:12.780 --> 00:21:14.600
some section of their job.

00:21:14.600 --> 00:21:20.380
And or kids, you know, tinkers just trying to play with a Raspberry Pi or something.

00:21:20.380 --> 00:21:22.520
Yeah, it's actually that's a really good point.

00:21:22.600 --> 00:21:24.960
They actually touch on that a little bit in the article.

00:21:24.960 --> 00:21:30.560
They say for professionals that have long relied upon trawling through spreadsheets, Python

00:21:30.560 --> 00:21:31.880
is especially valuable.

00:21:31.880 --> 00:21:37.360
And they point out that Citigroup, the American Bank, has even put together a crash course for

00:21:37.360 --> 00:21:38.780
Python for its analysts.

00:21:38.780 --> 00:21:46.000
And the eFinancialCareers, like a website for financial jobs, found that there's like a four

00:21:46.000 --> 00:21:51.960
time increase in the request for Python skills in the last three years among financial analysts,

00:21:52.100 --> 00:21:52.640
not programmers.

00:21:52.640 --> 00:21:53.380
Oh, nice.

00:21:53.380 --> 00:21:53.640
Yeah.

00:21:53.640 --> 00:21:56.680
So there's a lot of interesting little tidbits of stuff coming out of this article.

00:21:56.680 --> 00:21:57.420
Yeah, cool.

00:21:57.420 --> 00:21:58.620
Yeah, definitely worth checking out.

00:21:58.620 --> 00:21:59.260
All right.

00:21:59.260 --> 00:22:00.260
Well, I think that's it.

00:22:00.260 --> 00:22:01.940
That's our six items for the week.

00:22:01.940 --> 00:22:04.340
Brian, you got anything else you want to share with everyone while you're here?

00:22:04.820 --> 00:22:07.020
No, I've been having my head in antiques.

00:22:07.020 --> 00:22:13.160
So if anybody's a listener in the Portland area, hit me up and I'll tell you where I'm going

00:22:13.160 --> 00:22:14.920
to be selling some antiques this Sunday.

00:22:14.920 --> 00:22:17.020
So it's a completely non-Python job.

00:22:17.820 --> 00:22:22.360
It's kind of nice every now and then to just take a step away, put the keyboard down and

00:22:22.360 --> 00:22:24.920
do something really different so you can come back more refreshed, right?

00:22:24.920 --> 00:22:25.480
Yeah.

00:22:25.480 --> 00:22:26.380
You got any news?

00:22:26.380 --> 00:22:27.420
No, not this week.

00:22:27.420 --> 00:22:30.440
Although I'm working on something big that I will announce next week.

00:22:30.440 --> 00:22:33.480
So I'm close to having news, but I'm not quite there yet.

00:22:33.480 --> 00:22:34.220
All right.

00:22:34.220 --> 00:22:34.700
Nice.

00:22:34.840 --> 00:22:36.040
I'll bring a little extra news next week.

00:22:36.040 --> 00:22:36.660
All right.

00:22:36.660 --> 00:22:39.180
Well, Brian, thanks for doing this and sharing with everyone.

00:22:39.180 --> 00:22:40.460
And thank you everyone for listening.

00:22:40.460 --> 00:22:40.820
Thanks.

00:22:40.820 --> 00:22:41.120
Bye.

00:22:41.120 --> 00:22:41.440
Yep.

00:22:41.440 --> 00:22:44.940
Thank you for listening to Python Bytes.

00:22:44.940 --> 00:22:47.500
Follow the show on Twitter via at Python Bytes.

00:22:47.500 --> 00:22:50.400
That's Python Bytes as in B-Y-T-E-S.

00:22:50.400 --> 00:22:53.820
And get the full show notes at pythonbytes.fm.

00:22:53.820 --> 00:22:58.160
If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

00:22:58.160 --> 00:23:00.900
We're always on the lookout for sharing something cool.

00:23:00.900 --> 00:23:04.260
On behalf of myself and Brian Okken, this is Michael Kennedy.

00:23:04.780 --> 00:23:07.880
Thank you for listening and sharing this podcast with your friends and colleagues.