WEBVTT
00:00:00.001 --> 00:00:05.860
We've come to the end of 2019. Python 2 has just a handful of days before it goes unsupported,
00:00:05.860 --> 00:00:11.500
and I've met up with Dan Bader from realpython.com to look back at the year of Python articles on his
00:00:11.500 --> 00:00:16.920
website. We dive into the details behind 10 of his most important articles from the past year.
00:00:16.920 --> 00:00:22.300
This is Talk Python To Me, episode 244, recorded November 8th, 2019.
00:00:22.300 --> 00:00:40.320
Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the
00:00:40.320 --> 00:00:45.100
ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where
00:00:45.100 --> 00:00:49.620
I'm at mkennedy. Keep up with the show and listen to past episodes at talkpython.fm,
00:00:49.620 --> 00:00:54.360
and follow the show on Twitter via at talkpython. This episode is sponsored by
00:00:54.360 --> 00:00:58.880
linodeandbrilliant.org. Please check out what they're offering during their segments. It really
00:00:58.880 --> 00:01:03.620
helps support the show. Hey there. I want to take just a moment before we get to the interview
00:01:03.620 --> 00:01:10.860
and say thank you. It's the end of 2019. Looking back, it's been a great year for the podcast and
00:01:10.860 --> 00:01:15.260
all the other stuff we're doing, like our courses, and it's been really humbling to get messages from
00:01:15.260 --> 00:01:21.000
all of you about how the podcast is helping you in some way or the benefits you're getting from it.
00:01:21.000 --> 00:01:25.800
And I just want to say thank you for listening because it's a true honor to be able to create
00:01:25.800 --> 00:01:31.280
this podcast for you. It's a lot of work, but it's entirely worth it. It's really, really great,
00:01:31.280 --> 00:01:36.860
and it couldn't be done without you listening and sharing it. So thank you, thank you, thank you.
00:01:36.860 --> 00:01:40.760
Hope your 2019 was great as well. Now let's chat with Dan.
00:01:41.720 --> 00:01:43.380
Dan, welcome back to Talk Python To Me.
00:01:43.380 --> 00:01:44.540
Hey, it's great to be back, man.
00:01:44.540 --> 00:01:47.580
It's great to have you back. It's been a while since you've been on Talk Python, but
00:01:47.580 --> 00:01:50.840
not too long ago since you were on Python Bytes. That was fun.
00:01:50.840 --> 00:01:55.680
Yeah, that's right. We practically just finished recording that. And yeah, it was great with
00:01:55.680 --> 00:01:58.760
Cecil Phillips and yeah, I had some good links that week, I think.
00:01:58.760 --> 00:02:03.720
Yeah, absolutely. So I'm pretty excited about 2019. It was a good year. How was it for you?
00:02:03.720 --> 00:02:07.360
It was a very, very busy year, I would say.
00:02:07.360 --> 00:02:13.580
Yeah, I feel like for you guys, like RealPython has come along a long ways. You've got a lot of
00:02:13.580 --> 00:02:17.720
authors, you've kind of got this process going, you've got your editorial, your editing, and
00:02:17.720 --> 00:02:22.140
overseeing how the content creation is going. And you're making a big difference, I think.
00:02:22.140 --> 00:02:29.400
Thanks. That's good to hear. And yeah, it's just been this incredible year. We're at 75 authors and
00:02:29.400 --> 00:02:33.660
video instructors published on the site now. So I want to get to 100 next year. That would be a nice,
00:02:34.180 --> 00:02:41.900
cool achievement, I think. And we also just recently hit 2 million visitors, like unique visitors or
00:02:41.900 --> 00:02:47.960
readers in a single month, which is kind of this incredible... Let me... I can almost... It totally
00:02:47.960 --> 00:02:53.820
sounds like I'm super bragging here, but I literally can't wrap my brain around that. It's just kind of
00:02:53.820 --> 00:02:59.240
nuts and really cool just to see that growth and how it's resonating and how we're getting really,
00:02:59.240 --> 00:03:00.480
really positive feedback. Yeah.
00:03:00.560 --> 00:03:02.840
Yeah. I think that's really positive and congratulations.
00:03:02.840 --> 00:03:03.400
Thank you.
00:03:03.400 --> 00:03:08.800
Yeah. And I think it speaks one to all the work that you're doing that you talked about. It also speaks
00:03:08.800 --> 00:03:14.440
to just Python's growth in general, right? Like you're riding two curves and they're both going
00:03:14.440 --> 00:03:15.180
in the right direction.
00:03:15.180 --> 00:03:17.420
Yeah, that's true. So how was your 2019?
00:03:17.420 --> 00:03:24.360
My 2019 was amazing. Didn't skip a single episode on any of the podcasts. And I think that's a pretty big
00:03:24.360 --> 00:03:25.400
accomplishment actually.
00:03:25.400 --> 00:03:26.380
That's huge. Yeah.
00:03:26.480 --> 00:03:31.640
Yeah. And released a bunch of classes. I feel like we've covered some important stories
00:03:31.640 --> 00:03:36.900
on the podcast, right? That's one of the things I try to do. We can cover every web framework
00:03:36.900 --> 00:03:40.900
and the person who creates it and that's great and so on. But I really want to highlight that
00:03:40.900 --> 00:03:46.100
Python is not just for web developers or like straight down the middle of the road data scientists.
00:03:46.100 --> 00:03:46.460
Yeah.
00:03:46.600 --> 00:03:54.220
We've had medieval Islamic philosophers and we've had people doing machine learning for particle
00:03:54.220 --> 00:04:00.360
collisions and all sorts of stuff that might have been back in 2018. But those kinds of stories are really
00:04:00.360 --> 00:04:05.400
interesting. I think we had a decent amount of those and I'm really happy to be able to share
00:04:05.400 --> 00:04:07.820
those edge stories that I think are so interesting.
00:04:07.820 --> 00:04:12.400
Yeah. Yeah. I think that's super cool. And then I think a podcast is just such a great format for it as well,
00:04:12.400 --> 00:04:18.680
where somebody can come on the show and join you there and really give the listener a chance to
00:04:18.680 --> 00:04:23.360
understand why this is cool and what the motivation. That's always the most interesting thing for me
00:04:23.360 --> 00:04:27.820
when I listen to your show, figuring out like, okay, why is your guest doing that? Why are they so into
00:04:27.820 --> 00:04:33.080
researching Islamic philosophy with Python, which are two topics that I would have never imagined
00:04:33.080 --> 00:04:37.480
you would combine in some way. And then I listened to the show and I'm like, oh man, it's so cool how
00:04:37.480 --> 00:04:39.720
broad this is, what people are doing with Python.
00:04:39.720 --> 00:04:43.900
Yeah. You listen to the story and it makes perfect sense. You're like, of course you should be doing
00:04:43.900 --> 00:04:48.260
that. And the thing I like about those types of stories is there's a lot of people that think,
00:04:48.260 --> 00:04:52.760
oh, I'm not a programmer or it doesn't make sense for me to do that or whatever. Like,
00:04:52.760 --> 00:04:57.680
I'm just a stock trader. I'm just a biologist. And then you hear that and you're like, all right,
00:04:57.680 --> 00:05:02.440
if somebody can use it for philosophy, thousand year old scrolls, I should be able to find a way to
00:05:02.440 --> 00:05:08.080
make use of this in my much more mainstream type of job. Right. It's like, yeah, obviously there's all
00:05:08.080 --> 00:05:10.700
these amazing things people can do. They just got to be a little creative to do it.
00:05:10.700 --> 00:05:14.240
Yeah. Yeah, absolutely. I feel like we talked about this before, but this whole idea of the dark
00:05:14.240 --> 00:05:19.280
matter developer, someone who doesn't actually really identify as a developer or programmer,
00:05:19.280 --> 00:05:25.440
but there's so many people out there who are practically programmers or they're working with
00:05:25.440 --> 00:05:29.120
code, they're writing code, but they don't really see it that way.
00:05:29.120 --> 00:05:34.740
A big enough part of the community to actually come along and come to the conferences or blog about
00:05:34.740 --> 00:05:37.680
programming. They're probably blogging about something else that they care about. Something
00:05:37.680 --> 00:05:38.180
like that, right?
00:05:38.180 --> 00:05:38.700
Yeah. Yeah.
00:05:38.700 --> 00:05:39.340
Yeah. Sweet.
00:05:39.340 --> 00:05:43.440
Cool. Well, let's talk about what we're going to focus on for this show. So the idea is we're going
00:05:43.440 --> 00:05:49.360
to take 10 of your popular bookicles, book articles, your articles-
00:05:49.360 --> 00:05:50.020
That should be a new one.
00:05:50.020 --> 00:05:50.640
Yeah.
00:05:50.640 --> 00:05:56.620
So we're going to take our near book style on real Python and just pick 10 of them. We're going to
00:05:56.620 --> 00:06:02.480
call it the top 10, but it's not necessarily top 10 by your traffic. It's kind of the ones you wanted
00:06:02.480 --> 00:06:03.540
to highlight from the year, right?
00:06:03.540 --> 00:06:11.400
Yeah. So yeah, I really wanted to give a chance to sample a wider variety of topics because if you go
00:06:11.400 --> 00:06:16.320
purely by traffic numbers, things are just going to get overshadowed by popular terms that people
00:06:16.320 --> 00:06:16.940
search for on Google.
00:06:16.940 --> 00:06:19.920
Look, it's for Django articles or whatever, right? And just because people are searching for that or
00:06:19.920 --> 00:06:20.180
whatever.
00:06:20.180 --> 00:06:26.160
Yeah. And so, yeah. So we kind of assembled a list of 10 articles that we wanted to highlight and then
00:06:26.160 --> 00:06:27.960
go over and then share with you.
00:06:27.960 --> 00:06:28.880
All right. Where are we starting?
00:06:28.880 --> 00:06:34.440
Sweet. So we're starting with an article that's called How to Run Your Python Scripts by
00:06:34.440 --> 00:06:41.700
Leo Danis Pozo Ramos. And it kind of sounds simple, right? You just go-
00:06:41.700 --> 00:06:45.200
Right. Don't you just say python space script.py?
00:06:45.200 --> 00:06:47.920
Yeah. I mean, that's what we do most of the time, right?
00:06:47.920 --> 00:06:48.620
Some of the time, yeah.
00:06:48.620 --> 00:06:56.260
Hit control R or something like that. F5. And this article is cool because it, of course,
00:06:56.360 --> 00:07:02.240
talks about that. But then it goes really, really deep into the behind the scenes and
00:07:02.240 --> 00:07:07.780
what some of the other ways are that you can possibly use to run Python code. So you could
00:07:07.780 --> 00:07:14.580
just load the string from Office Script and then just eval it. Or there's the import lib module
00:07:14.580 --> 00:07:21.180
in Python 3 that you could use. And there's all kinds of other more complex methods where you get
00:07:21.180 --> 00:07:22.960
deeper and deeper into CPython.
00:07:22.960 --> 00:07:27.200
You could do python space dash C and like some code, right?
00:07:27.200 --> 00:07:32.060
You could also do that if you wanted to run a code snippet from the command line. And I just love this
00:07:32.060 --> 00:07:36.840
article because it starts with the really simple and straightforward and like main use case. And then
00:07:36.840 --> 00:07:41.520
it goes deeper and deeper and deeper into all the different alternatives. And you know, what the
00:07:41.520 --> 00:07:48.220
difference is between running a module with Python dash M versus actually just running it by Python
00:07:48.220 --> 00:07:53.760
space from the command, Python space and then the file of the file name and running it from the
00:07:53.760 --> 00:07:57.740
command line. And yeah, for that reason, you know, I wanted to highlight that article.
00:07:57.740 --> 00:08:01.460
Okay. Yeah, that's really cool. And one of the things I like about a couple of the articles that
00:08:01.460 --> 00:08:07.060
we're covering are I look at the title and I go, yeah, I know that. And then I look at the article
00:08:07.060 --> 00:08:11.800
and it's like, I don't know how many words, but it's like, you know, readability suggests this might
00:08:11.800 --> 00:08:15.680
be an over an hour to read this article. I'm like, wait, I thought I just, that was simple and I knew it.
00:08:15.680 --> 00:08:20.620
And you know, when you, whenever I, that kind of makes me think, I'm like, oh, I actually might learn
00:08:20.620 --> 00:08:25.000
something here. If I just pay attention, like this is going deeper or into a different area than,
00:08:25.160 --> 00:08:28.480
because if I thought it was that simple and it's this, then it's clearly I'm missing something.
00:08:28.480 --> 00:08:33.100
Yeah. As the kind of the person running the site and working on the platform there, like I love
00:08:33.100 --> 00:08:37.960
seeing surprises like that because it's always a team of us that's working on the article. So we
00:08:37.960 --> 00:08:43.100
have like multiple review stages and we review the outline and then we review the script and there's
00:08:43.100 --> 00:08:49.500
like a technical review and just seeing these things kind of grow and you'll become a real Python
00:08:49.500 --> 00:08:54.940
article is, I just really enjoy that process and being a part of it. So yeah, this is like a great
00:08:54.940 --> 00:08:59.600
example, I think, of that. Yeah. Yeah. Quite cool. So covers a bunch of stuff and probably something,
00:08:59.600 --> 00:09:04.600
you know, there's definitely a few suggestions in there that I didn't know. All right. What's number
00:09:04.600 --> 00:09:11.580
two? And number two is called 13 Project Ideas for Intermediate Python Developers by Habib
00:09:11.580 --> 00:09:19.780
Shopeyou. And this was born out of a lot of questions that we received over email or Twitter and
00:09:19.780 --> 00:09:25.380
also most recently in our real Python community Slack where people were asking, like, I feel like
00:09:25.380 --> 00:09:30.620
I kind of know how to use Python, but I don't know what I should build. I've learned the language. I know
00:09:30.620 --> 00:09:35.220
loops. I know how to do strings. I create a dictionary, get stuff in and out of it. But what can I actually
00:09:35.220 --> 00:09:37.500
build that like is the next step? Exactly.
00:09:37.760 --> 00:09:42.940
Yeah. Because that's often very challenging. It's not just challenging on like maybe a lack
00:09:42.940 --> 00:09:47.560
of creativity. It's challenging in like, oh, you want to be cool to build Instagram? Like, no,
00:09:47.560 --> 00:09:50.440
it wouldn't be cool to build. It'd be very hard to build. It's like millions of lines of code.
00:09:50.440 --> 00:09:53.980
You know what would be cool to build? As a timer, like, no, it's boring and it's too short. Like,
00:09:53.980 --> 00:09:59.660
what is the right size where it's challenging, but I can reasonably expect to do it if I put in some
00:09:59.660 --> 00:10:03.220
effort? Yeah. And that's a really hard one, right? Like I was back in the day when I learned how to
00:10:03.220 --> 00:10:07.400
code or first started. I mean, I guess you never really stopped learning how to program.
00:10:07.400 --> 00:10:12.140
I was in these like game development forums and there was every single week there was like
00:10:12.140 --> 00:10:17.000
a new person joining and they were like, I want to build this MMORPG or like, I want to build this
00:10:17.000 --> 00:10:21.200
like massive thing. And so everybody was working on these like massive projects that never really
00:10:21.200 --> 00:10:25.980
went anywhere. And I think that could be really, really frustrating. And so my answer to that question,
00:10:25.980 --> 00:10:29.980
you know, what should I build as an intermediate developer was usually like, just pick whatever,
00:10:29.980 --> 00:10:34.820
you know, just take a command line app that you use and try to emulate, like try to write your own
00:10:34.820 --> 00:10:39.040
version of it. But the problem is that doesn't really work for some learners, for some students.
00:10:39.040 --> 00:10:42.860
And so we wanted to give them a list with ideas, you know, here's some things that we think you could
00:10:42.860 --> 00:10:47.880
probably pull off. You have a fighting chance of actually like building this app, right? And it's
00:10:47.880 --> 00:10:52.680
not going to be a world of Warcraft, but it's going to be a cool like alarm tool or a little file
00:10:52.680 --> 00:10:58.160
manager or a little note-taking application. Yeah. Give us a sense of some of the ideas you got there.
00:10:58.160 --> 00:10:59.720
Yeah. So the ones that I just mentioned.
00:10:59.720 --> 00:11:08.680
Yeah, exactly. So MP3 player, URL shortener, file rename. Yeah. That's really nice.
00:11:08.680 --> 00:11:12.840
Contact book, I think is also something interesting where, you know, there's different ways you could
00:11:12.840 --> 00:11:18.180
store the data could just be like a little, yeah, like an address book where maybe you ask, you know,
00:11:18.180 --> 00:11:23.800
it could be as simple as just storing a dictionary to a text file, or then you could get progressively
00:11:23.800 --> 00:11:26.920
more interesting there and have a little database maybe.
00:11:26.920 --> 00:11:30.880
You could use SQLite and then you could start using SQLAlchemy because, you know, you don't
00:11:30.880 --> 00:11:35.100
want to be writing inline SQL and then, you know, become little Bobby tables.
00:11:35.100 --> 00:11:39.600
Yeah, that's right. Well, you know, someone could take you a great free MongoDB course.
00:11:39.920 --> 00:11:42.360
Yeah, exactly. Yeah. They could do a MongoDB back one.
00:11:42.360 --> 00:11:43.000
All kinds of options there.
00:11:43.000 --> 00:11:46.480
Yeah. They could totally like level these up. They could put them online, all kinds of cool
00:11:46.480 --> 00:11:50.680
stuff. Yeah. So I like it. And you got it broken down to web, GUI and command line. That's pretty
00:11:50.680 --> 00:11:50.940
good break.
00:11:50.940 --> 00:11:54.660
Yeah, that's right. Yeah. We try to give like a high level overview and then depending on what
00:11:54.660 --> 00:11:57.480
you're interested in, you could pick the right project for you.
00:11:57.480 --> 00:11:59.160
Yeah. Super. All right. What's next?
00:11:59.160 --> 00:12:05.100
All right. So I think we are at article number three. And what I wanted to highlight there is
00:12:05.100 --> 00:12:11.400
the article is called Three Ways of Storing and Accessing Lots of Images in Python by Rebecca Stone.
00:12:11.400 --> 00:12:16.360
And I think this article is cool because, again, it's something that I never really thought about
00:12:16.360 --> 00:12:21.060
before. You know, I was like, OK, you know, my Django app uses a bunch of static images.
00:12:21.060 --> 00:12:22.700
There's just a folder in there.
00:12:22.700 --> 00:12:25.540
Right, right. That's slash static slash IMG or something, right?
00:12:25.540 --> 00:12:31.200
Yeah. But what if that maybe doesn't work so great anymore? I think you're storing a
00:12:31.200 --> 00:12:36.060
massive amount of images. You know, you have some, I don't know, some robot, some probe that's going
00:12:36.060 --> 00:12:40.620
to Mars and you have lots, you have like terabytes of images. And where are you going to store them?
00:12:40.620 --> 00:12:42.020
How are you going to make this manageable?
00:12:42.020 --> 00:12:48.740
Right. Are you going to create some kind of like automated IoT doorbell that always snapshots,
00:12:48.740 --> 00:12:49.580
whatever's close, right?
00:12:49.580 --> 00:12:54.020
Yeah. And if your house gets broken in a lot, eventually you have too many images and you got
00:12:54.020 --> 00:12:55.680
to figure out what to do with them.
00:12:55.680 --> 00:12:58.180
That's right. Why are all these people at my house? You're killing my storage.
00:12:58.180 --> 00:12:59.720
All right. So what are some of the suggestions?
00:12:59.720 --> 00:13:05.520
Yeah. So it goes, the article goes into three techniques there. So the first one is, you know,
00:13:05.520 --> 00:13:10.900
just like store them on disk as .png files or, you know, JPEG or what have you. And then the
00:13:10.900 --> 00:13:16.660
second option is using a memory mapped database called LMDB. And the third option is using a
00:13:16.660 --> 00:13:27.140
hierarchical hierarchical data format like HDF5. And the latter two, I'd never really heard about before.
00:13:27.140 --> 00:13:34.140
But it turns out, of course, that there is a lot of Python tooling available for these things.
00:13:34.800 --> 00:13:39.980
And so they provide a number of interesting features. So for example, there's a compression
00:13:39.980 --> 00:13:46.440
that you could use. So to potentially limit your disk usage. And there's just lots of good tooling,
00:13:46.440 --> 00:13:50.260
if that's a problem that you're facing, that people can use with Python.
00:13:50.260 --> 00:13:55.440
Yeah, this is interesting. Like I'd never heard of LMDB, but apparently it's lightning memory mapped
00:13:55.440 --> 00:13:57.340
databases, which sounds fascinating.
00:13:57.340 --> 00:14:01.560
It sounds, yeah. It's like, I should definitely check that out. Find a use case for that. Cause that
00:14:01.560 --> 00:14:01.980
sounds cool.
00:14:01.980 --> 00:14:05.220
Yeah. You got to build that, that magical doorbell robot.
00:14:05.220 --> 00:14:10.140
Right. Maybe selfies for robots or something. They just do it all day long. All right. Awesome.
00:14:10.140 --> 00:14:12.100
All right. So what's number four?
00:14:12.100 --> 00:14:17.420
Number four is called Speed Up Your Python Program with Concurrency by Jim Anderson.
00:14:17.420 --> 00:14:20.180
Oh, this is one that definitely, definitely resonates with me.
00:14:20.180 --> 00:14:27.560
It's, yeah, you have a lot of great material on asyncio and working with parallelism and concurrency
00:14:27.560 --> 00:14:36.040
with Python. And the idea for this article was to give the reader an overview of what different
00:14:36.040 --> 00:14:41.860
types of concurrency that are out there. And what does it mean if a program is CPU bound versus IO bound
00:14:41.860 --> 00:14:47.940
and which options make sense using, you know, when should you use threading versus a multi-processing
00:14:47.940 --> 00:14:54.260
or asyncio. And we also added an interactive quiz to it. So that, you know, if you're reading this,
00:14:54.260 --> 00:14:57.540
you can really make sure, okay, I actually understood these concepts because they're pretty
00:14:57.540 --> 00:14:59.280
difficult to take in the first time.
00:14:59.280 --> 00:15:03.020
Yeah. That's the kind of thing that just needs to wash over you several times until you're like,
00:15:03.020 --> 00:15:05.480
all right, I'm starting, I'm starting to get the feel of this thing.
00:15:05.480 --> 00:15:09.840
Yeah. Get burned by it a couple of times and you're like, oh no, I got to re-architect this again.
00:15:09.840 --> 00:15:14.620
Exactly. And I think this is important in Python because I think Python's concurrency story
00:15:14.620 --> 00:15:21.500
is both amazing, but non-obvious in some ways. And what I mean by that is a lot of programming
00:15:21.500 --> 00:15:27.560
languages, you can leverage computational concurrency by using just threads, right? Because I got, you
00:15:27.560 --> 00:15:32.100
know, this thing believes it has 12 threads in my MacBook here. It has six hyper-threaded cores,
00:15:32.100 --> 00:15:37.560
right? So if I were to like write a single-threaded program, it'll get like eight or 9% CPU usage
00:15:37.560 --> 00:15:41.860
and that's it. So if I want to make that go faster on a lot of languages, C++, C#, whatever,
00:15:41.860 --> 00:15:45.680
I can just create a bunch of threads and it can start running on all of those different threads.
00:15:45.680 --> 00:15:50.840
But in Python, we have the gill, so it doesn't work, right? And that's, I think, actually caused a lot
00:15:50.840 --> 00:15:55.400
of challenges because people say, well, that means Python's concurrency is broken. It's not broken.
00:15:55.400 --> 00:15:59.420
It just needs a clearer mental model of when to apply each technique.
00:15:59.420 --> 00:16:01.920
Yeah. It's kind of like a manual gear shift, right?
00:16:01.920 --> 00:16:02.400
Yeah. Yeah.
00:16:02.400 --> 00:16:04.920
It's not broken, but the car is also not going to go.
00:16:04.920 --> 00:16:09.640
It drives in the day, but it won't drive at night. Put it in night mode. It won't go.
00:16:09.640 --> 00:16:10.460
Put it in N.
00:16:11.660 --> 00:16:17.400
Yeah, exactly. So for example, if it's IO bound, probably what you want to do is something
00:16:17.400 --> 00:16:22.840
to do with asyncio, right? But if it's computational, you really need to do, at least for the moment,
00:16:22.840 --> 00:16:24.220
something with multiprocessing.
00:16:24.220 --> 00:16:24.340
Yeah.
00:16:24.340 --> 00:16:26.000
And so it compares those types of things, huh?
00:16:26.000 --> 00:16:30.700
Yeah, exactly. And like I said, you know, we have this quiz at the end that you can take
00:16:30.700 --> 00:16:35.120
and then really make sure, okay, I understand what the differences are between these concurrency
00:16:35.120 --> 00:16:35.460
models.
00:16:35.460 --> 00:16:41.780
This portion of Talk Python To Me is brought to you by Linode. Whether you're working on a personal
00:16:41.780 --> 00:16:47.280
project or managing your enterprise's infrastructure, Linode has the pricing, support, and scale that you
00:16:47.280 --> 00:16:52.320
need to take your project to the next level. With 11 data centers worldwide, including their newest
00:16:52.320 --> 00:16:59.100
data center in Sydney, Australia, enterprise-grade hardware, S3-compatible storage, and the next-generation
00:16:59.100 --> 00:17:03.820
network, Linode delivers the performance that you expect at a price that you don't.
00:17:03.820 --> 00:17:10.140
Get started on Linode today with a $20 credit and you get access to native SSD storage, a 40-gigabit
00:17:10.140 --> 00:17:15.380
network, industry-leading processors, their revamped cloud manager at cloud.linode.com,
00:17:15.380 --> 00:17:22.180
root access to your server, along with their newest API and a Python CLI. Just visit talkpython.fm
00:17:22.180 --> 00:17:27.380
slash Linode when creating a new Linode account and you'll automatically get $20 credit for your
00:17:27.380 --> 00:17:32.620
next project. Oh, and one last thing. They're hiring. Go to linode.com slash careers to find
00:17:32.620 --> 00:17:34.420
out more. Let them know that we sent you.
00:17:34.420 --> 00:17:37.660
Number five.
00:17:37.660 --> 00:17:43.560
All right. Number five. Build a recommendation engine with collaborative filtering by Abinaf
00:17:43.560 --> 00:17:47.120
Aitzeria. And what do you think this is?
00:17:47.120 --> 00:17:53.220
I'm reading a real Python article and it says, you might also like these other three or something
00:17:53.220 --> 00:17:57.360
like that or talk Python course. You might also like this one, right? It's a good follow-on
00:17:57.360 --> 00:18:01.500
for various reasons, right? People who took this course usually took that one next or people who
00:18:01.500 --> 00:18:05.320
read this article also like shared that other article or something.
00:18:05.320 --> 00:18:10.340
Yeah, exactly. It's about building a recommender or recommendation engines like you would have on,
00:18:10.340 --> 00:18:16.620
you know, pretty much any larger website like Netflix or Amazon. They're all recommending you
00:18:16.620 --> 00:18:22.080
products or movies that you might enjoy based on what you already watched. And a lot of times what
00:18:22.080 --> 00:18:28.020
they do is they look at, kind of build a profile of the things that you watched and then kind of
00:18:28.020 --> 00:18:33.220
finding similar users, other users on the platform that watched those movies and enjoyed them. And
00:18:33.220 --> 00:18:37.040
then based on that, trying to figure out, okay, what did these other people also watch and enjoy?
00:18:37.040 --> 00:18:40.800
And maybe we can recommend that back to you and then hopefully you'll have a good time on the
00:18:40.800 --> 00:18:41.100
platform.
00:18:41.100 --> 00:18:45.020
Yeah, that sounds really cool. It sounds like very relevant to data scientists and there's probably
00:18:45.020 --> 00:18:47.060
a lot of data science algorithms in there, huh?
00:18:47.060 --> 00:18:51.280
Yeah, absolutely. I think there's some cool stuff happening there and there's some matrix math.
00:18:51.940 --> 00:18:56.300
What I like about this article that I really like how it turned out from like a typesetting
00:18:56.300 --> 00:19:01.340
perspective. So that was like a really big aspect of kind of building the new real Python
00:19:01.340 --> 00:19:07.440
CMS and hosting platform and built on Python 3, Django 2 and all the good things. It was a lot of fun
00:19:07.440 --> 00:19:12.360
building it and working on it. And I mean, I'm still working on it. And I think this is just a cool
00:19:12.360 --> 00:19:16.720
showcase for that also, you know, where you get some graphs in there, you get some interactive,
00:19:16.940 --> 00:19:21.640
or you get some code snippets that you can copy and paste and you get some math typesetting there.
00:19:21.640 --> 00:19:28.480
And I think that makes it very engaging to the reader as well. And yeah, and it's just a cool
00:19:28.480 --> 00:19:33.360
topic. Like I'm just fascinated by those things, you know, how you can use the wisdom of crowds or
00:19:33.360 --> 00:19:36.360
whatever that way. You know, you could say like, well, we have enough people using the platform,
00:19:36.360 --> 00:19:39.960
you have enough people watching Netflix. And then all of a sudden I can get these amazing
00:19:40.340 --> 00:19:42.500
recommendations for other things I would have never thought about watching.
00:19:42.500 --> 00:19:45.560
Yeah. You help it make it better for other people without even knowing it, right?
00:19:45.560 --> 00:19:45.860
Yeah.
00:19:45.860 --> 00:19:50.740
Your actions are there and used for good. Yeah. So it talks about things like K nearest neighbors
00:19:50.740 --> 00:19:55.100
and probably the fundamental algorithm there that's being used, right?
00:19:55.100 --> 00:20:00.800
Yeah. I believe it's for this particular recommendation system technique called collaborative
00:20:00.800 --> 00:20:06.040
filtering. But there's also other approaches that I can't really speak intelligently about.
00:20:06.040 --> 00:20:11.380
Yeah, sure. There's even some cool recommendations like the surprise recommender system, which is a
00:20:11.380 --> 00:20:17.400
Python scikit-learn extension, right? So you can install scikit-surprise.
00:20:17.400 --> 00:20:19.780
It's a cool name for recommender system.
00:20:19.780 --> 00:20:23.940
That's a great recommender, right? Like surprise, we actually can recommend something useful. This is
00:20:23.940 --> 00:20:26.060
not like wasted space here. Yeah.
00:20:26.060 --> 00:20:31.040
Cool. Yeah. So if people are interested, they can check that out. And also I noticed it's kind of
00:20:31.040 --> 00:20:35.460
got this bimodal way of working which says, well, if you want to use pip, here's how you do it. If you want to use
00:20:35.460 --> 00:20:40.440
Anaconda, here's how you use that as well, right? So this one seems like there'd be a lot of folks
00:20:40.440 --> 00:20:44.240
using Anaconda as their Python distribution to work on this.
00:20:44.240 --> 00:20:50.140
Yeah. I think if in the data science space, Conda seems to be quite popular. And so typically we kind
00:20:50.140 --> 00:20:54.500
of standardize like for the articles, we standardize on just using pip because that's kind of the lowest
00:20:54.500 --> 00:20:55.980
common denominator. Yeah.
00:20:55.980 --> 00:21:02.020
But in this case, you know, we felt like it makes sense to be closer to where the target audience might
00:21:02.020 --> 00:21:04.360
be there. Right, right. Take it to the data scientists, right?
00:21:04.880 --> 00:21:06.120
Yeah.
00:21:06.120 --> 00:21:08.460
That's really cool. So I love it. It's a good one.
00:21:08.460 --> 00:21:11.380
Number six on our list here.
00:21:11.380 --> 00:21:16.000
Right. So this one might be a bit surprising, but it is called Your Guide to the Python Print
00:21:16.000 --> 00:21:16.540
Function.
00:21:16.540 --> 00:21:20.780
And this is the one that I was talking about when I thought like, okay, I'd know this thing.
00:21:20.780 --> 00:21:21.360
Yeah.
00:21:21.360 --> 00:21:23.060
Like, wait a minute, maybe I don't know this thing.
00:21:23.140 --> 00:21:33.360
So this is more like a book about the Python print function by Bartosz Zaszinski. And this is just this
00:21:33.360 --> 00:21:39.900
incredible deep dive into the print function slash print statement in Python 2. Because again, you know,
00:21:39.900 --> 00:21:43.540
would think, okay, maybe this is maybe a paragraph or two about what you can do with the print function.
00:21:43.540 --> 00:21:45.340
You know, you can pass some arguments to it.
00:21:45.340 --> 00:21:47.120
It requires parentheses now. It didn't used to.
00:21:47.320 --> 00:21:52.380
Exactly. Right. Like what else is there to say? And then it goes really, really deep into the
00:21:52.380 --> 00:21:58.820
history of the print function and some common use cases that maybe you might not associate with the
00:21:58.820 --> 00:22:03.140
print function directly upon first glance. You know, for example, well, how can you build a cool
00:22:03.140 --> 00:22:10.120
console user interface? How can you do colors in the terminal? And how can you pretty print if you
00:22:10.120 --> 00:22:14.320
have a nested data structure, like some JSON that you parsed into dictionary? How can you make sure
00:22:14.320 --> 00:22:20.620
it actually looks good when you print it out to the console or some debug window? And so it's not
00:22:20.620 --> 00:22:25.820
just purely about the print function, but all the kinds of different best practices and ways you can
00:22:25.820 --> 00:22:28.000
make printing better in your Python programs.
00:22:28.000 --> 00:22:33.600
Yeah, that's cool. No one wants to try to use a minified dictionary for debugging.
00:22:33.600 --> 00:22:39.400
Nope. That's very annoying. I usually take those and then paste them into the black online
00:22:39.400 --> 00:22:45.020
format. I get like a nicer representation. Yeah. Yeah. Yeah. So we cover some of the things I
00:22:45.020 --> 00:22:50.260
think are actually not super obvious to new folks coming from the language, right? Like
00:22:50.260 --> 00:22:55.660
that's right. If you come from other languages, you might not know that you can actually use a
00:22:55.660 --> 00:23:01.400
keyword argument to set the end to be instead of a backslash end to be like a comma and print on one
00:23:01.400 --> 00:23:06.120
line with a bunch of commas or something like that or the buffering, right? If I'm trying to do
00:23:06.120 --> 00:23:11.140
something computational and print out as the computation is happening, a lot of times that
00:23:11.140 --> 00:23:15.520
can get buffered up and then it like all shoots out at once. Or, you know, like if you're like
00:23:15.520 --> 00:23:19.880
delaying waiting on something, you want to actually see all the output. Like there's a bunch of little
00:23:19.880 --> 00:23:24.060
tips like that in there, right? Yeah. Yeah. And like with everything, it's there's a deep rabbit hole.
00:23:24.580 --> 00:23:30.180
Yeah. Down the rabbit hole you go, right? Yeah. I love this kind of article where you think, okay,
00:23:30.180 --> 00:23:34.560
we're going to scratch the surface here a little bit and then we're done. And then there's all kinds
00:23:34.560 --> 00:23:40.420
of interesting other things you could do or just learn why certain things work the way they do. You
00:23:40.420 --> 00:23:48.200
know, ANSI or ANSI escape sequences for making the making colors in the terminal. When you read about
00:23:48.200 --> 00:23:52.800
them, they kind of looks like this incredibly confusing format. And then you learn a bit more
00:23:52.800 --> 00:23:57.740
about the history and you know how it relates to the sort of these old school terminals of the old
00:23:57.740 --> 00:24:03.460
like mainframe computers and how, you know, it's just a format that has grown over decades. And
00:24:03.460 --> 00:24:07.720
well, sure, we could all, you know, throw it away and maybe engineer something from scratch. But it's kind
00:24:07.720 --> 00:24:12.300
of cool to understand, you know, if I'm, if I don't know, you know, boot up my Windows computer or
00:24:12.300 --> 00:24:18.620
MacBook in, in 2020, why it's still supporting that stuff and how it goes back, you know, 50 years.
00:24:18.620 --> 00:24:23.640
Yeah. Well, another thing that I think makes a night and day difference for these simple little
00:24:23.640 --> 00:24:29.780
command line apps is color. More of those should use color, right? If you're saying in the help output,
00:24:29.780 --> 00:24:34.320
it would be great to show the required arguments is like one color and the optional ones is another.
00:24:34.480 --> 00:24:40.500
And it's incredibly easy. But if you don't know to do it, or you think it's hard, or it's hard to do
00:24:40.500 --> 00:24:42.120
cross platform or whatever, then you won't.
00:24:42.120 --> 00:24:47.680
Yeah. Yeah. Oh, speaking of color there in the terminal, one of my favorite tools is the B Python
00:24:47.680 --> 00:24:48.200
REPL.
00:24:48.200 --> 00:24:49.200
B Python?
00:24:49.200 --> 00:24:56.520
B Python. So the letter B, and then Python, one word. It's a Python interpreter, like a Python, not an
00:24:56.520 --> 00:25:01.240
interpreter, but a REPL environment. That is just like the when you start Python from a command line,
00:25:01.300 --> 00:25:05.840
you get your little prompt and you can type a Python code into it and run it. But it does
00:25:05.840 --> 00:25:09.060
syntax highlighting. So it'll give you beautiful colors in the terminal.
00:25:09.060 --> 00:25:09.440
Nice.
00:25:09.440 --> 00:25:12.340
And it also does autocomplete, which is kind of cool.
00:25:12.340 --> 00:25:18.140
So we use that all the time in our video courses and examples. And people always ask like,
00:25:18.140 --> 00:25:21.080
oh, what's that? What's that tool? I want to use that too. And it's great. Like,
00:25:21.080 --> 00:25:23.040
like the color really adds a lot of value.
00:25:23.040 --> 00:25:27.620
It adds a lot. Yeah. I maybe, I think I've heard of B Python. I haven't used it. I'm all about the
00:25:27.620 --> 00:25:29.340
PT Python. Are you familiar with that?
00:25:29.340 --> 00:25:29.980
Oh, that's great too. Yep.
00:25:29.980 --> 00:25:36.480
Yeah. It's like Emacs in the REPL kind of. Yeah. It takes me back to my Emacs days. So last thing,
00:25:36.480 --> 00:25:41.560
like we go on and on about this, like incredibly for a really long time about printing. But there's
00:25:41.560 --> 00:25:45.340
one thing that's in here. I think that's, that's pretty interesting that they talk about that I guess
00:25:45.340 --> 00:25:50.620
also surprised me. I didn't really think about it is mocking the print function for unit tests.
00:25:50.620 --> 00:25:56.260
Yeah. That's a kind of a surprise, right? But it's, it's actually a pretty annoying problem. If you,
00:25:56.260 --> 00:26:00.140
if you want to write tests for a program where in the test, you actually want to make sure it's
00:26:00.140 --> 00:26:04.400
printing the right stuff. Well, how do you do it? You know, how can you actually redirect that output
00:26:04.400 --> 00:26:09.520
into some kind of buffer so you can inspect it and say, okay, we got the output that we wanted.
00:26:09.520 --> 00:26:14.620
I called this and it said, enter this or whatever, right? Like the prompt that we were expecting or
00:26:14.620 --> 00:26:20.160
something. Yeah. Yeah. Yeah. Yeah. Pretty cool. All right. Well, let's move on because it is the
00:26:20.160 --> 00:26:24.800
print function, but it is actually really, really interesting. And what are we up to number?
00:26:24.800 --> 00:26:30.760
I am trying to check. I think number seven, this is number seven. Yes. Number seven. Yeah. And it
00:26:30.760 --> 00:26:36.620
goes right along to number eight in a sense. So how to write beautiful Python code with PEP 8.
00:26:36.620 --> 00:26:44.120
Yeah. So this is a cool article by Jasmine Feiner and it's about the PEP 8 style guide and sort of
00:26:44.120 --> 00:26:51.980
a beginner friendly intro to PEP 8, why it exists, how it can help you format your code in a way that
00:26:51.980 --> 00:26:58.740
other Python developers will expect and appreciate. And I think it's, it's a really good one because,
00:26:58.740 --> 00:27:04.040
you know, it breaks it. Like if, when you read the actual PEP 8 can be feedback that I heard in the
00:27:04.040 --> 00:27:08.940
past, it's just very, very overwhelming to take it all in and take all the examples in. So we try to
00:27:08.940 --> 00:27:15.980
break it down and give you a good overview and then point you to the original PEP so you can do the deep
00:27:15.980 --> 00:27:20.240
dive. Yeah. It's really cool. And you know, it's one of those things that's really important that,
00:27:20.240 --> 00:27:28.340
so you look like you belong, right? If you start doing stuff that is, you know, Java style or C#
00:27:28.340 --> 00:27:34.020
style and someone says, yeah, I'm interviewing for a Python job. And here, let me write a little
00:27:34.020 --> 00:27:40.260
code for you and you start using like camel case method names or something like that. You're like,
00:27:40.260 --> 00:27:45.200
not so sure you're a Python developer. You don't look like you're from around here, right?
00:27:45.200 --> 00:27:48.500
Yeah. First impressions matter, I guess.
00:27:48.500 --> 00:27:52.620
Yeah. And you know, once you know the conventions, some of those conventions have meaning,
00:27:52.620 --> 00:27:59.780
right? Like the underscore has a certain meaning and things like that. And so it's not implicitly
00:27:59.780 --> 00:28:04.000
obvious from that thing that what the meaning is. But once you study it, then you get to know,
00:28:04.000 --> 00:28:04.180
right?
00:28:04.180 --> 00:28:09.580
Yeah. Yeah. I'm actually, I wanted to ask you what's, is your talk Python, is the code for the
00:28:09.580 --> 00:28:11.560
talk Python platform? Is it PEP 8 compliant?
00:28:11.560 --> 00:28:12.960
Is it PEP 8 compliant?
00:28:12.960 --> 00:28:18.700
It's both for the platform it is, I would say PEP 8 compliant. And I try to do that in the courses.
00:28:18.700 --> 00:28:24.660
Probably the way I do that most is just running, like working on everything in PyCharm and PyCharm
00:28:24.660 --> 00:28:29.100
will highlight stuff and make it obviously, it'll like, as you type a highlight, it'll go, no,
00:28:29.100 --> 00:28:33.020
no, no, no. There's something clearly wrong. Like you don't have an underscore, you have camel case
00:28:33.020 --> 00:28:38.880
on a variable name. Stop doing that. Right. And so, yeah, I don't run anything like black across
00:28:38.880 --> 00:28:44.520
the whole thing. The only thing I've run entirely across the whole code base, not across the courses
00:28:44.520 --> 00:28:49.100
because it's recorded. So it'd be weird to change it. But in terms of the platform, I've used Flint.
00:28:49.100 --> 00:28:50.160
Are you familiar with Flint?
00:28:50.160 --> 00:28:54.360
I feel like I heard about it. Is this another auto format?
00:28:54.360 --> 00:29:00.440
It has, it's a very special tool, but I love it. What it does is it will take all the various string
00:29:00.440 --> 00:29:08.600
formatting styles of working with strings. So percent, value value, or the format, something
00:29:08.600 --> 00:29:10.920
or other, and so on. And it turns on all the f-strings.
00:29:10.920 --> 00:29:11.660
Oh, that's cool.
00:29:11.660 --> 00:29:14.060
Yeah. It'll just rewrite your code, like rewrite all your f-strings.
00:29:14.060 --> 00:29:17.940
I know a certain core Python developer who would love that. Marietta.
00:29:17.940 --> 00:29:20.080
She does all these awesome stickers.
00:29:20.080 --> 00:29:26.620
Yeah, yeah. Yes, man. Yeah. So I ran it. In the early days, it had a couple of bugs when you were doing
00:29:26.620 --> 00:29:34.400
numerical formatting, like this number, comma, colon, comma, like 0.2F. Like that would get freaked out.
00:29:34.400 --> 00:29:37.580
But yeah, like after a couple of iterations, it's really quite good.
00:29:37.580 --> 00:29:40.400
Oh, that's cool. I think, yeah, I got to run that. That's great.
00:29:40.400 --> 00:29:44.720
Yeah. So I just ran it against like 20,000 lines of code across the training site and the Talk Python
00:29:44.720 --> 00:29:49.300
and Python Bytes websites. And I think there was like maybe one mistake. So I just,
00:29:49.420 --> 00:29:52.980
I looked at the diff before I checked them all in and just said, actually this, you know,
00:29:52.980 --> 00:29:55.340
one out of a thousand, there's this mistake. But yeah, yeah.
00:29:55.340 --> 00:29:57.640
I think actually those are probably pretty much gone. But yeah, anyway,
00:29:57.640 --> 00:30:00.820
and it's not PEP 8, but it's a sort of a continuation.
00:30:00.820 --> 00:30:05.940
Yeah. And I think with this stuff, I feel like we've got to be clear, like it can often be ambiguous,
00:30:05.940 --> 00:30:09.700
right? Like any, any sort of code style guide, like PEP 8 or what have you, you know,
00:30:09.700 --> 00:30:15.540
in other languages, it's usually not at the end of the day, like naming is a big part of a
00:30:15.540 --> 00:30:18.180
developer's job, I think, you know, and in picking names that are
00:30:18.760 --> 00:30:21.440
actually communicating the intent well and other people can understand.
00:30:21.440 --> 00:30:26.380
And so it's, it's, it's not going to solve that problem because, well, even though if,
00:30:26.380 --> 00:30:30.280
you know, if you're following PEP 8 to a T and you're using all the upper and lowercase letters
00:30:30.280 --> 00:30:35.460
in the, in the right way, and your naming isn't, just doesn't make sense, then that's also not
00:30:35.460 --> 00:30:38.160
going to be great. So it's, yeah, another example might be struggle.
00:30:38.480 --> 00:30:43.160
Yeah. You're doing a list comprehension and it's all on one line, right? It's got the,
00:30:43.160 --> 00:30:49.980
you know, and for N and such and such, if N such and such. And it happens to be 79 line characters
00:30:49.980 --> 00:30:54.880
long. So it's on column 79. It's fine. You don't need to wrap it, but it's like super hard to
00:30:54.880 --> 00:31:00.180
understand. It would make sense to have that three lines, the select value, the loop, the,
00:31:00.180 --> 00:31:04.340
the collection is going through and the test, right? It would be much better. But PEP 8 doesn't say,
00:31:04.340 --> 00:31:10.220
well, if it's 79 lines and complicated, it should be broken up. But 80 lines is, you know,
00:31:10.220 --> 00:31:13.940
like the hard limit and things like that, right? Yeah. Yeah. And so we've got to think beyond it.
00:31:13.940 --> 00:31:17.780
Are you following the 79 characters limit in your code basis?
00:31:17.780 --> 00:31:24.280
Do I follow? Sometimes. There's a few times where I don't like, so if I have a, a raw string or
00:31:24.280 --> 00:31:28.700
multi-line, not raw string, a multi-line string where you do triple quote, then like there's a bunch of
00:31:28.700 --> 00:31:33.760
stuff and then triple quote to close it. I don't know of a way to not do more than 80 lines. If what needs to
00:31:33.760 --> 00:31:37.700
be in the string is more than, or 80 columns, but he would still complain to me like, oh no,
00:31:37.700 --> 00:31:41.620
this line is 120. I'm like, yeah, but you show me how to fix it and we'll have a conversation,
00:31:41.620 --> 00:31:45.240
but I can't fix this, right? Yeah. Without completely going, you know what, we're going to have a string
00:31:45.240 --> 00:31:51.800
concatenation like to nobody's end rather than this multi-line string. So there's a few edge cases,
00:31:51.800 --> 00:31:55.880
but I try to. Yeah, me too. Like ever since I started using black, you're like, black's going to change
00:31:55.880 --> 00:32:00.400
it anyway. I think you can tell it like to use a different line length limit. Like I feel like that's,
00:32:00.400 --> 00:32:05.140
that's always something that comes up where it's like a kind of controversial topic where should
00:32:05.140 --> 00:32:10.000
you follow the 79 character limit is even another, there's like a 72 character limit recommendation
00:32:10.000 --> 00:32:15.360
for doc strings. Like I try to follow that as well. I have like my, you know, these like a little,
00:32:15.360 --> 00:32:19.520
little gutter margin set up in the editor. So yeah, exactly. That's cool. But then at the,
00:32:19.520 --> 00:32:22.760
sometimes I'm thinking, okay, but wouldn't it be nice just to go a hundred characters or longer?
00:32:22.760 --> 00:32:25.960
So I think, I think like whatever number of people pick, as long as you're consistent,
00:32:25.960 --> 00:32:28.780
it's, it's probably a good thing. Yeah. It's somewhat contextual.
00:32:28.780 --> 00:32:35.520
This portion of Talk Python To Me is brought to you by Brilliant.org. Let me knock something off
00:32:35.520 --> 00:32:41.100
your holiday to-do list. Gifts. Spread the love to your loved ones by gifting them Brilliant.
00:32:41.100 --> 00:32:46.100
This really excites me because it's such a fun way to nurture curiosity, build confidence,
00:32:46.100 --> 00:32:50.920
and develop problem-solving skills crucial to school, job interviews, or to their career.
00:32:50.920 --> 00:32:55.600
Brilliant's thought-provoking content breaks up the complexities into bite-sized,
00:32:55.840 --> 00:33:01.620
understandable chunks that will lead them from curiosity to mastery. Go to talkpython.fm
00:33:01.620 --> 00:33:06.640
slash brilliant and grab a gift subscription to help your loved ones finish their day a little
00:33:06.640 --> 00:33:11.460
smarter this season. That's talkpython.fm/brilliant, or just click the link in the show notes.
00:33:13.620 --> 00:33:21.660
We talked about Pep 8. Now how about Article 8? Article 8 is about the Python Lambda function. So it's called
00:33:21.660 --> 00:33:28.780
How to Use Python Lambda Functions by Andre Bourgo. And yeah, I wanted to highlight this one because
00:33:28.780 --> 00:33:37.120
Lambdas and Python are a topic that can be challenging. I think it's something that a lot of times you don't
00:33:37.120 --> 00:33:41.680
really have to, you don't really work with. And so you don't get a lot of experience working with it.
00:33:41.680 --> 00:33:45.800
And then when there might be a situation where it's actually useful, for example, if you want to
00:33:45.800 --> 00:33:50.660
sort a list or something sorted by a custom key, then if you don't know about Lambdas,
00:33:50.660 --> 00:33:52.720
it's going to be a frustrating experience.
00:33:52.720 --> 00:33:56.780
Right, right. Like I got to write this other function and that's kind of weird. But yeah,
00:33:56.780 --> 00:34:01.420
so they're one of the things that when you learn them, you're like, man, that is cool. I can't
00:34:01.420 --> 00:34:06.220
believe I can think of immediately 10 places I would use this, but they're not obvious that they exist
00:34:06.220 --> 00:34:07.900
or that you could use them until you see them, right?
00:34:07.900 --> 00:34:12.940
Yeah, that's right. And it's, what's the quote there? Like the dose makes the poison or what?
00:34:12.940 --> 00:34:14.600
I only know the German version.
00:34:14.600 --> 00:34:15.760
Yeah.
00:34:15.760 --> 00:34:17.380
Die Dose macht das Gift.
00:34:17.380 --> 00:34:18.360
Yeah.
00:34:18.360 --> 00:34:19.940
So the dose makes the poison.
00:34:19.940 --> 00:34:24.760
Yeah. Basically you don't want to, you want to apply it. It's like salt, you know, you don't
00:34:24.760 --> 00:34:27.360
want to overdo it with the salt because then the food's going to taste it.
00:34:27.360 --> 00:34:31.280
Yeah. Yeah. A pinch will do you. Absolutely. So yeah, that sounds about right.
00:34:31.380 --> 00:34:37.940
Yeah. And so, so this article goes into some use cases and also into the kind of the language
00:34:37.940 --> 00:34:44.360
history or why are these types of functions called lambda functions and how does this relate to this
00:34:44.360 --> 00:34:50.200
thing called lambda calculus that was invented in the 1930s. And we go back into some of the computer
00:34:50.200 --> 00:34:51.080
science stuff.
00:34:51.080 --> 00:34:52.480
Yeah, that's cool.
00:34:52.480 --> 00:34:53.800
So you can also learn about that.
00:34:53.900 --> 00:34:57.880
You know, another thing that I think is interesting that gets very little attention,
00:34:57.880 --> 00:35:03.700
I suspect this is happening to a non-trivial number of people and they don't even know is closure.
00:35:03.700 --> 00:35:08.720
Right? So closure is the idea that like I have a variable that's either available in the local
00:35:08.720 --> 00:35:14.260
method or it's a global variable. Most likely it's like a local variable on that method.
00:35:14.260 --> 00:35:21.540
We're using the lambda and you say it in the function body, the lambda body, but not as an argument.
00:35:22.320 --> 00:35:23.500
Right. It's somehow magically.
00:35:23.500 --> 00:35:25.280
Kind of capturing that.
00:35:25.280 --> 00:35:25.780
Yes.
00:35:25.780 --> 00:35:30.480
I find this so hard to explain just in audio only because when you see it with an example,
00:35:30.480 --> 00:35:35.440
like in the article, it's to me at least a lot easier to wrap my head around it.
00:35:35.440 --> 00:35:37.260
But yeah, let's give it a shot.
00:35:37.260 --> 00:35:37.700
Like can we.
00:35:37.700 --> 00:35:41.720
Yeah. Well, some really interesting stuff happens with closure, right?
00:35:41.720 --> 00:35:46.400
It's not just that the variable is like passed, but it's remembered.
00:35:46.400 --> 00:35:48.880
It's remembered across function calls.
00:35:49.040 --> 00:35:53.680
So even if you change it and then you call the lambda again, it will work with not the
00:35:53.680 --> 00:35:56.440
original value like a compi, but it'll work with a changed value.
00:35:56.440 --> 00:36:02.720
Which can really bite you also if you're referring to a mutable object and you think you've kind
00:36:02.720 --> 00:36:08.000
of captured the full state of this object and then it gets changed under you.
00:36:08.000 --> 00:36:13.920
which I think this is also kind of maybe the danger of using lambda is that if you don't
00:36:13.920 --> 00:36:21.440
understand how closures work or when that effect kicks in, that you might be writing code that
00:36:21.440 --> 00:36:24.620
actually breaks under unexpected circumstances.
00:36:24.620 --> 00:36:25.080
Yeah.
00:36:25.080 --> 00:36:29.040
And it can be incredibly hard to understand why if you have no idea that this is happening.
00:36:29.360 --> 00:36:33.000
On the flip side, you can use it for great power as well.
00:36:33.000 --> 00:36:35.360
Like let's just go to like something super simple.
00:36:35.360 --> 00:36:36.720
I want to sort a list.
00:36:36.720 --> 00:36:43.840
I want to say key equals lambda of item, colon, do something with the item, right?
00:36:43.840 --> 00:36:50.840
But maybe there's other variables or other data that's in the function that you want to use to
00:36:50.840 --> 00:36:51.920
decide how you sort.
00:36:51.920 --> 00:36:54.400
Like if it's below this cutoff, I want it first.
00:36:54.400 --> 00:36:59.060
But if it's after this cutoff or like, you know, it's somehow you've got to compute with some other
00:36:59.060 --> 00:37:01.380
data that's not purely just the item.
00:37:01.380 --> 00:37:06.600
Like if you wanted to sort, you had an address book with, I don't know, name and year of birth
00:37:06.600 --> 00:37:10.180
and you wanted to sort it by some calculated value.
00:37:10.180 --> 00:37:10.600
Yeah.
00:37:10.600 --> 00:37:11.760
So like both of them.
00:37:11.760 --> 00:37:12.400
Right, right.
00:37:12.400 --> 00:37:15.060
So if they don't have a date of birth, you could have like, here's the default date of
00:37:15.060 --> 00:37:15.860
birth we're going to use.
00:37:15.860 --> 00:37:16.300
Right, yeah.
00:37:16.300 --> 00:37:16.640
Right, right.
00:37:16.640 --> 00:37:17.200
Substitute something.
00:37:17.200 --> 00:37:19.100
Yeah, they're all going to be born in 1970 or something.
00:37:19.100 --> 00:37:19.480
Who knows?
00:37:19.480 --> 00:37:24.260
So you could like have that as a local variable, but then include that in your sort lambda.
00:37:24.260 --> 00:37:30.660
But the function that's getting called, it only takes the item and the list doesn't know
00:37:30.660 --> 00:37:32.220
about your need of this other variable.
00:37:32.220 --> 00:37:36.180
It's not going to pass it in, but you can just use closure to just capture it and just like
00:37:36.180 --> 00:37:40.140
bring in more arguments into your lambda than would otherwise be available.
00:37:40.140 --> 00:37:42.080
And that's a super powerful thing you can do.
00:37:42.340 --> 00:37:42.400
Yeah.
00:37:42.400 --> 00:37:42.820
Yeah.
00:37:42.820 --> 00:37:47.940
I think that probably the main use case, what I personally use them for, there's also
00:37:47.940 --> 00:37:53.720
a section in the article that talks about whether lambdas are, we can consider them pythonic
00:37:53.720 --> 00:37:54.300
or not.
00:37:54.300 --> 00:37:59.300
Because in PEP 8, which we just talked about, there's actually a recommendation there that
00:37:59.300 --> 00:38:02.160
says you should always use a def statement.
00:38:02.160 --> 00:38:07.000
So define a proper function instead of an assignment statement that binds a lambda expression directly
00:38:07.000 --> 00:38:07.800
to an identifier.
00:38:07.800 --> 00:38:11.660
And so this is like a strong discouragement to using lambdas.
00:38:11.660 --> 00:38:15.040
I think mainly when you actually, you want a named function.
00:38:15.580 --> 00:38:18.940
I think anytime you actually want a named function, you should probably not use a lambda.
00:38:18.940 --> 00:38:22.620
But if it's like a one-off thing, that's where I would use it.
00:38:22.620 --> 00:38:22.860
Yeah.
00:38:22.860 --> 00:38:26.580
You even talk about in your article a little bit, like anonymous functions, meaning they
00:38:26.580 --> 00:38:27.700
have no name.
00:38:28.180 --> 00:38:29.220
You're passing them somewhere.
00:38:29.220 --> 00:38:34.760
You're modifying the behavior like of the sort or whatever, but you're not naming the
00:38:34.760 --> 00:38:35.500
thing doing that.
00:38:35.500 --> 00:38:35.720
Yeah.
00:38:35.720 --> 00:38:36.340
That's right.
00:38:36.340 --> 00:38:40.120
And with great power comes great responsibility.
00:38:40.120 --> 00:38:40.780
That's right.
00:38:41.000 --> 00:38:47.480
I think one of the key essence of the lambda, like decide, should I make a separate function
00:38:47.480 --> 00:38:49.580
or should I make a lambda function?
00:38:49.580 --> 00:38:54.720
I think one of the key differences here, or the key decision, at least for me, is, is it
00:38:54.720 --> 00:39:01.180
going to be clearer to just plunk the implementation right here than to give it a good name and put
00:39:01.180 --> 00:39:01.700
it somewhere else?
00:39:01.700 --> 00:39:05.720
So if it made a lot of sense to give it a good name and put it over there, because it's kind
00:39:05.720 --> 00:39:10.440
of complicated, but the name tells you what it does and then use that as the sort, great,
00:39:10.440 --> 00:39:10.860
do that.
00:39:10.940 --> 00:39:15.080
But if it's like, I'm going to sort just by like sort of list of customers, it's just
00:39:15.080 --> 00:39:17.980
lambda of C colon goes to C dot name.
00:39:17.980 --> 00:39:18.780
Okay.
00:39:18.780 --> 00:39:22.880
Like it would be more confusing to move that away because then you have to be sure like
00:39:22.880 --> 00:39:23.660
sort by name.
00:39:23.660 --> 00:39:24.300
You're like, oh, wait a minute.
00:39:24.300 --> 00:39:25.560
Descending or ascending?
00:39:25.560 --> 00:39:29.940
Well, it used to, they renamed it to say sort by name ascending, but then they actually changed
00:39:29.940 --> 00:39:34.020
implementation to descending, but they forgot to rename it because they're afraid to break
00:39:34.020 --> 00:39:34.500
the code.
00:39:34.500 --> 00:39:38.080
And just like, there's all sorts of weird stuff if you move it away.
00:39:38.080 --> 00:39:43.080
So if it's clearer to have it like in line than lambda, otherwise not lambda.
00:39:43.080 --> 00:39:44.960
That's my test.
00:39:45.120 --> 00:39:46.040
That's a good rule of thumb.
00:39:46.040 --> 00:39:51.840
I feel like I mainly use lambdas for exactly that, that use case and otherwise try to stay
00:39:51.840 --> 00:39:52.280
away from them.
00:39:52.280 --> 00:39:54.280
If you have to line break a lambda, that's a problem.
00:39:54.280 --> 00:39:54.640
Yeah.
00:39:54.640 --> 00:39:54.900
Yeah.
00:39:54.900 --> 00:39:55.480
That's, yeah.
00:39:55.480 --> 00:39:57.220
That's maybe also a good heuristic, right?
00:39:57.220 --> 00:39:57.820
Where, yeah.
00:39:57.820 --> 00:39:58.320
Yeah.
00:39:58.320 --> 00:40:01.600
You could only have, you know, basically you can just put an expression into it.
00:40:01.600 --> 00:40:03.560
So that's the other thing that we haven't even talked about.
00:40:03.560 --> 00:40:06.840
So they're also limited in what you can actually put into a lambda function.
00:40:06.840 --> 00:40:07.020
Right.
00:40:07.020 --> 00:40:12.920
So you can pretty much just have a single expression that would also be the result of which will
00:40:12.920 --> 00:40:16.320
also be returned as the return value of that, of that function.
00:40:16.940 --> 00:40:23.780
And that also limits you, but of course you could use all kinds of ugly work to do something
00:40:23.780 --> 00:40:25.420
that you're not really supposed to do with them.
00:40:26.120 --> 00:40:26.520
Exactly.
00:40:26.520 --> 00:40:27.000
Exactly.
00:40:27.000 --> 00:40:31.700
But you can't have multi-line lambdas in Python, whereas you can in other languages.
00:40:31.700 --> 00:40:33.840
Like for example, C# has lambdas.
00:40:33.840 --> 00:40:37.800
They're basically the same idea, closure and all that, but you can put curly braces and make
00:40:37.800 --> 00:40:40.420
it 20 lines long if you think that's a good idea.
00:40:40.420 --> 00:40:41.780
That's like a great idea.
00:40:41.780 --> 00:40:43.620
JavaScript's kind of like that, right?
00:40:43.620 --> 00:40:48.480
You can like function curly or parenthesis argument and then just curly braces, right?
00:40:48.480 --> 00:40:56.000
So to tell you a secret, I feel like what forced me to understand closures was doing more JavaScript
00:40:56.000 --> 00:40:57.500
development because you cannot avoid them.
00:40:57.500 --> 00:40:59.400
Yeah, closure's all over the place in JavaScript, right?
00:40:59.400 --> 00:40:59.940
Yeah.
00:40:59.940 --> 00:41:00.260
Yeah.
00:41:00.260 --> 00:41:01.400
Yeah, it is for sure.
00:41:01.400 --> 00:41:02.980
And they have like similar ideas.
00:41:02.980 --> 00:41:06.580
They don't call it lambda, but like they have anonymous functions basically.
00:41:06.580 --> 00:41:07.020
Yeah, that's right.
00:41:07.020 --> 00:41:07.280
Yeah.
00:41:07.280 --> 00:41:08.280
All right.
00:41:08.280 --> 00:41:09.480
Are we already at number nine?
00:41:09.480 --> 00:41:10.120
Number nine.
00:41:10.120 --> 00:41:10.700
Number nine.
00:41:10.700 --> 00:41:11.260
There we go.
00:41:11.260 --> 00:41:12.380
Yeah.
00:41:12.380 --> 00:41:15.020
So number nine is about Python coding interviews.
00:41:15.020 --> 00:41:19.840
So the article is called How to Stand Out in a Python Coding Interview by James Timmons.
00:41:19.840 --> 00:41:27.380
And I felt that this is an important topic and it's hopefully also something useful for you,
00:41:27.380 --> 00:41:28.080
dear listener.
00:41:28.080 --> 00:41:32.220
Maybe you have a Python coding interview coming up or you're worried about, you know, when
00:41:32.220 --> 00:41:35.180
the day comes where somebody is going to grill you on your Python skills.
00:41:35.180 --> 00:41:41.640
And we put this article together to cover some common situations there, basically some tips
00:41:41.640 --> 00:41:47.900
that you can use to showcase your deep understanding of the Python programming language.
00:41:47.900 --> 00:41:51.220
Yeah, you've broken into a couple of sections, right?
00:41:51.220 --> 00:41:56.600
You've got like know your built-in functions, know the right data structure, take advantage
00:41:56.600 --> 00:41:57.940
of the standard library, right?
00:41:57.940 --> 00:42:01.360
If somebody says, I want you to use the quick sort, you're like, you know what?
00:42:01.360 --> 00:42:02.320
I created a list.
00:42:02.320 --> 00:42:02.940
Tim sort.
00:42:02.940 --> 00:42:04.380
Yeah, yeah, exactly.
00:42:04.380 --> 00:42:05.420
Or something like that, right?
00:42:05.420 --> 00:42:08.240
Or I think the data structures is super important.
00:42:08.340 --> 00:42:09.140
That's a great giveaway.
00:42:09.140 --> 00:42:14.320
Like I want you to get a bunch of, I don't know, say users and I want you in memory and
00:42:14.320 --> 00:42:18.040
I want you to look them up by ID and I want you to do that quickly, right?
00:42:18.040 --> 00:42:18.640
Like dictionary.
00:42:18.640 --> 00:42:19.460
Yeah, dictionary.
00:42:19.460 --> 00:42:20.940
Does look up quickly happen?
00:42:20.940 --> 00:42:21.700
Is that the question?
00:42:21.700 --> 00:42:22.580
Dictionary.
00:42:22.580 --> 00:42:25.700
Just yell dictionary.
00:42:25.700 --> 00:42:26.400
Dictionary.
00:42:26.400 --> 00:42:27.620
Exactly.
00:42:27.620 --> 00:42:29.940
Or unique or distinct.
00:42:29.940 --> 00:42:30.860
Okay, set, right?
00:42:30.860 --> 00:42:31.080
Yeah.
00:42:31.080 --> 00:42:31.840
Did they say distinct?
00:42:31.840 --> 00:42:32.680
They mean set, right?
00:42:33.140 --> 00:42:38.540
Like just right away, there's, you could have like a complicated 10 line for loop where
00:42:38.540 --> 00:42:39.840
you test, have you seen it before?
00:42:39.840 --> 00:42:41.100
Or set, right?
00:42:41.100 --> 00:42:44.280
Like that's both knowing the built-ins and knowing the right data structures, I think.
00:42:44.280 --> 00:42:44.500
Yeah.
00:42:44.500 --> 00:42:48.120
And it is so much good stuff in the Python standard library or in the core language, you
00:42:48.120 --> 00:42:52.260
know, another great one I think that's worth knowing about is in the collections module,
00:42:52.260 --> 00:42:53.740
the counter class.
00:42:53.740 --> 00:42:54.780
Oh yeah.
00:42:54.780 --> 00:42:59.700
It's if you ever need to count different items or, you know, how often does this string
00:42:59.700 --> 00:43:00.820
or this word occur?
00:43:00.820 --> 00:43:01.380
Right.
00:43:01.380 --> 00:43:02.860
I got a list of text.
00:43:02.860 --> 00:43:04.500
Like a whole bunch of domain names.
00:43:04.500 --> 00:43:07.020
I need to know like how many, each one of them appears.
00:43:07.020 --> 00:43:07.380
Right.
00:43:07.380 --> 00:43:09.920
That sounds like a challenge or it sounds like two lines.
00:43:09.920 --> 00:43:12.900
If you know counter, right?
00:43:12.900 --> 00:43:13.400
Yeah.
00:43:13.400 --> 00:43:16.880
You create a, you import collections, you create a counter, they're most common.
00:43:16.880 --> 00:43:17.500
Right.
00:43:17.500 --> 00:43:22.420
But like these things are incredibly simple when you know them, but if you don't know they
00:43:22.420 --> 00:43:24.180
exist, it's really challenging.
00:43:24.180 --> 00:43:28.920
And I think that's actually a problem from, not a problem, but a, a learning challenge
00:43:28.920 --> 00:43:31.400
kind of going back to your other article.
00:43:31.400 --> 00:43:35.680
I don't remember which number it was, but the one, I think maybe number two about all
00:43:35.680 --> 00:43:37.020
the projects, right?
00:43:37.020 --> 00:43:41.140
Like some of those projects would be really easy if you knew the right libraries.
00:43:41.140 --> 00:43:45.880
But if you thought I have to write this from pure Python from scratch and I've got to implement
00:43:45.880 --> 00:43:46.500
this stuff, right?
00:43:46.500 --> 00:43:48.960
Like, oh, that MP3 player is super hard.
00:43:48.960 --> 00:43:50.920
Like, let me get down to the bytes and look at it.
00:43:50.920 --> 00:43:56.200
Like, no, you pip install like the MP3 library or whatever, like it is that works with that,
00:43:56.200 --> 00:43:56.420
right?
00:43:56.420 --> 00:43:58.880
It's, there's a whole lot of options.
00:43:58.880 --> 00:44:03.120
And I think learning Python is challenging because you learn the language and you think
00:44:03.120 --> 00:44:05.400
you've done it, but you've only like hit the 10%.
00:44:05.400 --> 00:44:07.000
Now you've got to learn the standard library.
00:44:07.000 --> 00:44:11.160
Then you've got to learn everything on awesome Python or PyPI or, right?
00:44:11.160 --> 00:44:12.140
So there's these levels.
00:44:12.140 --> 00:44:17.760
And, you know, but I do think for tests, for interviewing, knowing the foundational stuff
00:44:17.760 --> 00:44:18.520
is most important.
00:44:18.520 --> 00:44:19.000
I agree.
00:44:19.000 --> 00:44:19.240
Yeah.
00:44:19.240 --> 00:44:23.740
And we were thinking, you know, we're going to pick stuff that is actually very likely to
00:44:23.740 --> 00:44:28.780
come up in an interview because in an interview, I think you're not going to get super specific.
00:44:28.780 --> 00:44:34.420
You know, you're not going to talk about the LMHDB or whatever the lightning memory database
00:44:34.420 --> 00:44:35.340
that we talked about earlier.
00:44:35.600 --> 00:44:40.280
That would be, nobody's going to expect, I mean, depending on the kind of role, but if
00:44:40.280 --> 00:44:43.260
it's, if it's data science, they might expect you to know NumPy.
00:44:43.260 --> 00:44:43.660
Right.
00:44:43.660 --> 00:44:47.460
If you've claimed, you know, Python, you better know NumPy at least cursory, right?
00:44:47.460 --> 00:44:47.640
Yeah.
00:44:47.640 --> 00:44:52.000
And if you claim that you, you especially better know about things like the collections module,
00:44:52.000 --> 00:44:53.520
you know, these like core things.
00:44:53.520 --> 00:44:53.820
Yeah.
00:44:53.820 --> 00:44:54.020
Yeah.
00:44:54.020 --> 00:44:54.600
For sure.
00:44:54.600 --> 00:44:55.000
Yeah.
00:44:55.000 --> 00:44:56.980
What about when you get stumped?
00:44:56.980 --> 00:45:00.180
What is your thoughts on like, you know, how do I do this thing?
00:45:00.180 --> 00:45:04.060
Like, you know, inside your thing, screaming, like I have no idea.
00:45:04.060 --> 00:45:04.120
Yeah.
00:45:04.120 --> 00:45:07.340
I start sweating profusely and shivering.
00:45:07.340 --> 00:45:09.760
Go into the fetal position.
00:45:09.760 --> 00:45:11.520
That's why I'm running my own company now.
00:45:11.520 --> 00:45:13.260
Yeah.
00:45:13.260 --> 00:45:14.080
No, that's a tough one.
00:45:14.080 --> 00:45:20.320
I think the advice that I would give is start asking questions because it's oftentimes not
00:45:20.320 --> 00:45:24.400
a good sign if you ask someone a question in an interview setting and they immediately launch
00:45:24.400 --> 00:45:28.360
into writing code or they feel like they're expected to know the answer off the bat.
00:45:28.360 --> 00:45:33.300
A lot of times what the interviewer will want to see is how are you approaching a problem?
00:45:33.420 --> 00:45:34.740
Are you able to get help?
00:45:34.740 --> 00:45:36.380
Are you able to ask intelligent questions?
00:45:36.380 --> 00:45:40.140
And even if you don't know the specifics, I mean, nobody really expects that, right?
00:45:40.140 --> 00:45:43.880
A lot of times if you can use Google, if you can use Stack Overflow, if you can use, you
00:45:43.880 --> 00:45:48.520
know, Talk Python and RealPython and all these sites that are available to you, you would have
00:45:48.520 --> 00:45:50.100
that in your normal working environment.
00:45:50.100 --> 00:45:55.380
You know, like I use Google and Stack Overflow like probably like hundreds of times in a productive
00:45:55.380 --> 00:45:55.720
day.
00:45:55.720 --> 00:46:00.140
I use it shamelessly without guilt or judgment, right?
00:46:00.140 --> 00:46:03.940
I mean, because there's a bunch of stuff that you need to know and then there's a bunch
00:46:03.940 --> 00:46:08.940
of stuff that just doesn't deserve to take up space in your memory, right?
00:46:08.940 --> 00:46:11.680
And you should just be able to go, I'm just going to Google it.
00:46:11.680 --> 00:46:14.740
I don't know what the right way to do this library with that thing is.
00:46:14.740 --> 00:46:15.920
I'm going to Google it.
00:46:16.160 --> 00:46:19.600
But just like actually knowing that it exists and I just don't remember quite how to use
00:46:19.600 --> 00:46:21.000
it, I think is like the big step.
00:46:21.000 --> 00:46:26.100
Like I know I know there's a counter thing and I know I can get it to group by the count.
00:46:26.100 --> 00:46:30.220
I just don't remember how to the steps to make that happen, right?
00:46:30.220 --> 00:46:31.820
Like I think that's okay.
00:46:31.820 --> 00:46:33.260
Yeah, I think that's totally okay.
00:46:33.260 --> 00:46:35.280
So just duck, duck, go it.
00:46:35.280 --> 00:46:36.120
Just bing it.
00:46:36.120 --> 00:46:37.520
Google it.
00:46:37.520 --> 00:46:39.760
Just duck, duck, go it.
00:46:39.760 --> 00:46:40.540
AltaVista it.
00:46:40.540 --> 00:46:41.600
I don't know what else is there.
00:46:41.600 --> 00:46:42.220
Yahoo it.
00:46:42.220 --> 00:46:42.920
Yeah, yeah.
00:46:42.920 --> 00:46:43.960
AltaVista.
00:46:43.960 --> 00:46:44.460
That's a good one.
00:46:44.460 --> 00:46:44.980
I remember that.
00:46:44.980 --> 00:46:45.700
That was good.
00:46:45.980 --> 00:46:50.800
One other thing I would sort of put out there is like a huge turnoff to me if I was
00:46:50.800 --> 00:46:52.540
interviewing, I did that for a while with people.
00:46:52.540 --> 00:46:55.980
If I feel like they are lying to me, they're done.
00:46:55.980 --> 00:46:57.220
I don't care if they seem good.
00:46:57.220 --> 00:47:00.180
If I say like, oh, how would you do that with SQLAlchemy?
00:47:00.180 --> 00:47:02.120
Oh, like I've used so much SQLAlchemy.
00:47:02.120 --> 00:47:06.380
And then you can tell like they've never, ever, ever seen it, right?
00:47:06.380 --> 00:47:09.480
Like they don't even, they can't even describe like, well, what I would do is create a class
00:47:09.480 --> 00:47:12.460
that derives from like another class and it maps to the database.
00:47:12.460 --> 00:47:14.160
Like that's a foreign idea.
00:47:14.800 --> 00:47:17.420
But they're claiming like they've used it in production.
00:47:17.420 --> 00:47:18.580
Like done.
00:47:18.580 --> 00:47:19.580
Not a good strategy.
00:47:19.580 --> 00:47:20.900
Not, I would, I don't know.
00:47:20.900 --> 00:47:21.260
How do you feel?
00:47:21.260 --> 00:47:22.900
Like, would you hire that person?
00:47:22.900 --> 00:47:24.760
Because everything else comes to the question, right?
00:47:24.860 --> 00:47:25.200
I agree.
00:47:25.200 --> 00:47:26.460
It's, it's, yeah.
00:47:26.460 --> 00:47:26.940
It's at that.
00:47:26.940 --> 00:47:29.940
You want to find, find out, would you ask the interviewer?
00:47:29.940 --> 00:47:33.480
I feel like you also want to find out, would you want to have this person on your team?
00:47:33.480 --> 00:47:34.460
Would you want to work with them?
00:47:34.460 --> 00:47:34.700
Right.
00:47:34.700 --> 00:47:36.360
Would I trust them to be?
00:47:36.360 --> 00:47:36.520
Yeah.
00:47:36.520 --> 00:47:40.420
They start making up stuff like, hey, you know, did you review that pull request or request?
00:47:40.420 --> 00:47:42.260
Or did you merge that hot fix?
00:47:42.260 --> 00:47:43.640
Or did you, I don't know, do that?
00:47:43.760 --> 00:47:47.420
And then you feel like you can't really rely on that person and it's not a good start.
00:47:47.420 --> 00:47:50.160
Or we're going to build an e-commerce backend.
00:47:50.160 --> 00:47:53.540
Who's done payment stuff before and feels like they can do it, right?
00:47:53.540 --> 00:47:54.960
And maybe not.
00:47:54.960 --> 00:47:55.260
I don't know.
00:47:55.260 --> 00:47:56.920
Definitely use floats for currency.
00:47:56.920 --> 00:47:57.520
Yeah.
00:47:58.940 --> 00:48:02.300
I don't know if we have that one in the list, but that's, that's also a really common question.
00:48:02.300 --> 00:48:06.280
I feel like where people are like, oh, what data type should you use to represent currency
00:48:06.280 --> 00:48:06.840
in your program?
00:48:06.840 --> 00:48:07.240
Right.
00:48:07.240 --> 00:48:07.740
Right.
00:48:07.740 --> 00:48:08.880
Integers probably.
00:48:08.880 --> 00:48:09.240
Yeah.
00:48:09.240 --> 00:48:09.480
Yeah.
00:48:09.480 --> 00:48:11.960
And then break it down to sense and then use integers.
00:48:11.960 --> 00:48:12.260
Yeah.
00:48:12.260 --> 00:48:13.000
Just round it.
00:48:13.000 --> 00:48:13.560
Just round it.
00:48:13.560 --> 00:48:13.660
Just round it.
00:48:13.660 --> 00:48:15.640
About a dollar.
00:48:15.640 --> 00:48:16.060
Yeah.
00:48:16.060 --> 00:48:19.720
It's all good.
00:48:19.720 --> 00:48:20.320
It's about a dollar.
00:48:20.320 --> 00:48:21.240
All right.
00:48:21.240 --> 00:48:24.660
Well, we're coming up on the grand finale here.
00:48:24.660 --> 00:48:26.980
And this is another one that I could, I'm very passionate about.
00:48:26.980 --> 00:48:28.280
I could riff on for a long time.
00:48:28.280 --> 00:48:33.800
So you'll have to stop me at some point, but it has to do with the object oriented programming
00:48:33.800 --> 00:48:35.540
component of Python.
00:48:35.540 --> 00:48:36.420
Yeah.
00:48:36.420 --> 00:48:42.960
So the article is called inheritance and composition, a Python OOP guide by Isaac Rodriguez.
00:48:42.960 --> 00:48:50.180
And I think inheritance and composition, that is the, one of the core pieces of object oriented
00:48:50.180 --> 00:48:50.620
programming.
00:48:50.620 --> 00:48:56.900
And in my experience, it's also the piece that if you're completely new to OOP and you're trying
00:48:56.900 --> 00:48:58.520
to understand, okay, well, how is this helpful?
00:48:58.520 --> 00:48:59.640
Like how does this work?
00:48:59.640 --> 00:49:01.520
It can be a sticking point for some people.
00:49:01.520 --> 00:49:01.660
Yeah.
00:49:01.660 --> 00:49:05.880
So we wanted to do a dedicated article that is, yeah, basically a deep dive on inheritance.
00:49:05.880 --> 00:49:10.420
It sounds a little bit like modeling with objects and just like some practices around
00:49:10.420 --> 00:49:10.680
that.
00:49:10.680 --> 00:49:11.020
Right.
00:49:11.020 --> 00:49:11.240
Yeah.
00:49:11.240 --> 00:49:17.380
And how do you go about like breaking down a hierarchy or like, I guess a domain into a
00:49:17.380 --> 00:49:18.240
hierarchy of objects?
00:49:18.240 --> 00:49:18.480
Yes.
00:49:18.480 --> 00:49:19.600
Yeah, exactly.
00:49:19.660 --> 00:49:20.180
That was getting at.
00:49:20.180 --> 00:49:23.640
And so maybe we should define inheritance and composition.
00:49:23.640 --> 00:49:25.140
I think inheritance is pretty clear.
00:49:25.140 --> 00:49:27.540
Composition might be a little less well known.
00:49:27.540 --> 00:49:31.280
So inheritance is, I want to model like a bunch of cars.
00:49:31.280 --> 00:49:37.220
So I have a basic car or just a car, but then I have a sports car that does sporty things,
00:49:37.220 --> 00:49:37.400
right?
00:49:37.400 --> 00:49:42.720
Maybe it has like paddle shifters or it has like a manual transmission mode that has additional
00:49:42.720 --> 00:49:43.400
functionality.
00:49:43.400 --> 00:49:46.400
So I might say, all right, well, the idea is what we're going to do is we're going to
00:49:46.400 --> 00:49:48.420
create a car and a sports car.
00:49:48.420 --> 00:49:51.860
And then maybe I want to have a track car that can also take slicks.
00:49:51.860 --> 00:49:53.340
Like, so it derives from sports car.
00:49:53.340 --> 00:50:01.140
And the deeper that those get, the more full of the abstractions can break down pretty hard,
00:50:01.140 --> 00:50:01.380
right?
00:50:01.380 --> 00:50:07.720
Like, you know, if you model creatures, I've got a living animal and then I've got a bird
00:50:07.720 --> 00:50:11.580
and then I've got, what do you do with a robot bird, right?
00:50:11.580 --> 00:50:12.660
Does it drive from bird?
00:50:12.660 --> 00:50:13.060
That's a hard one.
00:50:13.360 --> 00:50:13.520
Right.
00:50:13.520 --> 00:50:17.980
Like it, it has bird like things, but the animal eats, robot doesn't eat.
00:50:17.980 --> 00:50:18.180
Right.
00:50:18.180 --> 00:50:20.680
So like if you go too deep, it makes, it's a problem.
00:50:20.680 --> 00:50:20.920
Right.
00:50:20.920 --> 00:50:22.300
So that's inheritance, obviously.
00:50:22.300 --> 00:50:23.340
Composition.
00:50:23.340 --> 00:50:24.080
Tell us about it.
00:50:24.080 --> 00:50:24.620
So composition.
00:50:24.620 --> 00:50:27.680
So if inheritance defines is a relationship.
00:50:27.680 --> 00:50:33.480
So like a sports car is a car and the car is a vehicle and a vehicle is a thing or whatever
00:50:33.480 --> 00:50:33.940
machine.
00:50:33.940 --> 00:50:37.320
Composition defines a, has a relationship.
00:50:37.320 --> 00:50:43.320
So you can say, okay, a car has an engine or a car has a steering wheel.
00:50:43.320 --> 00:50:43.760
Right.
00:50:43.760 --> 00:50:44.820
And it has a transmission.
00:50:44.820 --> 00:50:49.320
Instead of making a sports car, maybe you just make a car with a sporty transmission.
00:50:49.320 --> 00:50:50.140
Right.
00:50:50.140 --> 00:50:55.460
And so the whole thing doesn't have to like, because I don't know, what if you have some
00:50:55.460 --> 00:50:58.060
kind of truck, but it also has like a manual shifting thing, right?
00:50:58.060 --> 00:50:59.300
It could, right.
00:50:59.300 --> 00:51:01.480
You wouldn't have a truck derived from a sports car.
00:51:01.480 --> 00:51:02.220
That would be weird.
00:51:02.220 --> 00:51:02.480
Right.
00:51:02.480 --> 00:51:07.840
But you could easily like interchange the parts and it, it helps really alleviate some
00:51:07.840 --> 00:51:10.060
of those like deep object hierarchies.
00:51:10.060 --> 00:51:10.560
I think.
00:51:10.560 --> 00:51:11.020
Yeah.
00:51:11.020 --> 00:51:11.060
Yeah.
00:51:11.060 --> 00:51:15.180
It's, it's basically another tool in your toolbox there for defining these relationships.
00:51:15.180 --> 00:51:19.960
Because if, if you define everything in terms of a inheritance relationship, then you end
00:51:19.960 --> 00:51:24.380
up with these unmaintainable, like the, you end up on the dark side of OOP.
00:51:24.380 --> 00:51:25.320
That's right.
00:51:25.320 --> 00:51:32.060
And like small changes to like a deep down base class can make absurd things in the end, like
00:51:32.060 --> 00:51:34.520
a robot that has to eat or something like that.
00:51:34.520 --> 00:51:36.560
Cause maybe the animal didn't eat at first and that made sense.
00:51:36.560 --> 00:51:38.800
But now later you realize all the animals have to eat.
00:51:38.800 --> 00:51:41.680
And then like, well, what do you do about the robot thing that we put there?
00:51:41.680 --> 00:51:46.140
Like that's where you use multiple inheritances, which is like a whole dutter of can of worms.
00:51:46.140 --> 00:51:48.980
That's a deep, that's a big can of worms as well for sure.
00:51:48.980 --> 00:51:50.360
But I, I'm a big fan of composition.
00:51:50.360 --> 00:51:54.800
I think, I can't remember where I heard, I'm pretty sure the original gang of four design
00:51:54.800 --> 00:51:57.940
patterns books said prefer composition over inheritance.
00:51:57.940 --> 00:51:59.040
Yeah.
00:51:59.040 --> 00:52:00.840
Like you want shallow hierarchies.
00:52:00.840 --> 00:52:01.100
Yeah.
00:52:01.140 --> 00:52:05.000
Like you're going to like it's objects and inherits aren't inherently bad, but they're
00:52:05.000 --> 00:52:06.040
easy to abuse.
00:52:06.040 --> 00:52:11.240
And so composition is a really way, good way to keep those shallow and interchangeable and
00:52:11.240 --> 00:52:11.640
small.
00:52:11.640 --> 00:52:13.760
So yeah, quite, quite cool.
00:52:13.760 --> 00:52:14.780
I like this one a lot.
00:52:14.780 --> 00:52:15.100
Wow.
00:52:15.100 --> 00:52:16.880
Did we really make it to the, all the way?
00:52:16.880 --> 00:52:20.180
Oh, actually speaking of the gang of four book, I think that might be a recommendation
00:52:20.180 --> 00:52:23.480
here at the end of the article because we, yeah.
00:52:23.480 --> 00:52:24.340
Also always give.
00:52:24.340 --> 00:52:24.560
Yeah.
00:52:24.560 --> 00:52:26.780
So the article comes with recommended reading, right?
00:52:26.780 --> 00:52:27.080
Yeah.
00:52:27.080 --> 00:52:27.400
Yeah.
00:52:27.400 --> 00:52:29.900
It's got some cool design, design patterns.
00:52:30.340 --> 00:52:34.940
head first design patterns, clean code, solid principles, list cove substitution principle,
00:52:34.940 --> 00:52:36.080
all those kinds of things.
00:52:36.080 --> 00:52:36.240
Yeah.
00:52:36.240 --> 00:52:37.160
A lot of these apply.
00:52:37.160 --> 00:52:44.400
It would be remiss of us, I think, to riff so fondly on like an object oriented story in
00:52:44.400 --> 00:52:50.500
Python without seeing that like a lot of what people do with objects and classes and other
00:52:50.500 --> 00:52:53.360
languages is simply unnecessary in Python.
00:52:53.360 --> 00:52:53.760
Right.
00:52:54.080 --> 00:52:58.920
So there is a little bit of pushback and well, I know you did Java and everything had
00:52:58.920 --> 00:52:59.620
to be a class.
00:52:59.620 --> 00:53:01.660
You don't have to build it this way.
00:53:01.660 --> 00:53:01.900
Right.
00:53:01.900 --> 00:53:07.300
Like for example, if you have a variable that you need to be basically a singleton and then
00:53:07.300 --> 00:53:11.820
you want to group a bunch of functions together, you could have a static class that has those
00:53:11.820 --> 00:53:15.180
in there in like Java or C# or something like that.
00:53:15.420 --> 00:53:21.740
But you could also in Python just have a module that has a variable and it has functions.
00:53:21.740 --> 00:53:26.920
And then if you just import that module, you say that module dot the fields or the
00:53:26.920 --> 00:53:29.960
variables or the functions, that's the same thing as a static class.
00:53:29.960 --> 00:53:30.160
Right.
00:53:30.160 --> 00:53:30.380
Yeah.
00:53:30.380 --> 00:53:30.720
Right.
00:53:30.720 --> 00:53:35.320
You don't have, and you don't, it saves you a bunch of work and it's, it's more Pythonic.
00:53:35.320 --> 00:53:35.660
Yes.
00:53:35.740 --> 00:53:36.100
I guess.
00:53:36.100 --> 00:53:36.380
Right.
00:53:36.380 --> 00:53:38.160
Then making everything a class.
00:53:38.160 --> 00:53:38.460
Yeah.
00:53:38.460 --> 00:53:43.100
So there, I mean, maybe there's a little bit of, do I really need a class for that?
00:53:43.100 --> 00:53:43.780
Right.
00:53:43.780 --> 00:53:47.200
If you're going to create different ones over there, different values at the same time, like,
00:53:47.200 --> 00:53:47.800
well, probably.
00:53:47.800 --> 00:53:48.100
Right.
00:53:48.100 --> 00:53:50.920
But maybe if you're like just trying to group stuff, maybe the modules, right thing.
00:53:50.920 --> 00:53:56.100
But if you do decide and it does make sense to have a class, this inheritance versus composition
00:53:56.100 --> 00:53:57.620
thing is super important to understand.
00:53:57.620 --> 00:53:58.460
Yeah, absolutely.
00:53:58.460 --> 00:54:02.060
And I don't want to give the impression that like, you know, if you, if you're writing in an object
00:54:02.060 --> 00:54:05.500
oriented programming state style, that that's somehow superior or like the end
00:54:05.500 --> 00:54:07.400
all, you know, of, of coding.
00:54:07.400 --> 00:54:09.220
I don't, I don't think that's, that's actually true.
00:54:09.220 --> 00:54:13.560
I think the really powerful thing is understanding these tools, like to have a really
00:54:13.560 --> 00:54:17.620
big toolbox and being able to pick the things that make the most sense.
00:54:17.620 --> 00:54:20.800
Like a lot of times, you know, when, when I'm writing a program in Python or I'm sketching
00:54:20.800 --> 00:54:24.920
something out, I, I'll hardly like write any classes depending on, on the use case.
00:54:24.920 --> 00:54:30.460
Or I found myself, you know, most recently just basically adding like these, like, so I've
00:54:30.460 --> 00:54:35.180
been working on the real Python platform a lot and I've been writing more function-based
00:54:35.260 --> 00:54:41.680
codes or procedural code where maybe my data model is class-based, but then I'll have,
00:54:41.680 --> 00:54:47.060
you know, a module or I don't know, redeeming access codes or coupon codes or something like
00:54:47.060 --> 00:54:47.220
that.
00:54:47.220 --> 00:54:50.680
And it basically defines like a really nice high level interview interface to me.
00:54:50.680 --> 00:54:54.360
These are the five operations you do on coupons or something, right?
00:54:54.360 --> 00:54:54.540
Yeah.
00:54:54.540 --> 00:54:54.800
Yeah.
00:54:54.800 --> 00:54:56.320
And that's all function-based.
00:54:56.320 --> 00:54:56.660
Yeah.
00:54:56.660 --> 00:55:01.480
And then internally they, they use classes to kind of represent the data and, and shuffle
00:55:01.480 --> 00:55:01.840
it around.
00:55:01.840 --> 00:55:03.960
Probably working with Django ORM or something like that.
00:55:04.040 --> 00:55:04.200
Right.
00:55:04.200 --> 00:55:04.520
Yeah.
00:55:04.520 --> 00:55:04.880
Yeah.
00:55:04.880 --> 00:55:04.980
Yeah.
00:55:04.980 --> 00:55:09.300
Instead of cramming that all into a view or actually I prefer, for example, a function-based
00:55:09.300 --> 00:55:12.840
views in Django instead of class-based views because I don't like sort of the getting the
00:55:12.840 --> 00:55:13.740
deeper intendation.
00:55:13.740 --> 00:55:20.140
I would, we could, we could get into all kinds of, disagreements there, but, yeah,
00:55:20.140 --> 00:55:23.620
just, just want to make sure, you know, that, that I get this across that, I don't
00:55:23.620 --> 00:55:30.100
think the OOP coding style is, not the one true way that the one true way that this
00:55:30.100 --> 00:55:31.760
should be one, exactly one way to do things.
00:55:31.760 --> 00:55:32.180
Yeah.
00:55:32.180 --> 00:55:32.460
Yeah.
00:55:32.460 --> 00:55:35.520
But if you're going to do it, like understanding this, this difference between inheritance
00:55:35.520 --> 00:55:37.340
composition, certainly, it certainly makes sense.
00:55:37.340 --> 00:55:39.060
I do a lot of what you're recommending there as well.
00:55:39.060 --> 00:55:39.740
All right.
00:55:39.740 --> 00:55:42.180
Well, that's our top 10 items, Dan.
00:55:42.180 --> 00:55:42.740
Yeah.
00:55:42.740 --> 00:55:45.220
That, that went by super fast.
00:55:45.300 --> 00:55:45.460
Yeah.
00:55:45.460 --> 00:55:49.880
It did go by fast, but I think these all have special value and, you know, people might
00:55:49.880 --> 00:55:51.120
be kicking back.
00:55:51.120 --> 00:55:53.520
A lot of folks have vacation time around this time of year.
00:55:53.520 --> 00:55:57.920
You know, they're also thinking of what's coming in the next year in 2020.
00:55:57.920 --> 00:56:05.180
I mean, first of all, let's just take a moment and say, thank you, Python 2, but goodbye.
00:56:05.180 --> 00:56:05.580
Yeah.
00:56:05.580 --> 00:56:05.980
Bye-bye.
00:56:05.980 --> 00:56:07.540
We'll miss you.
00:56:07.540 --> 00:56:12.060
The death plot is down to single digit days probably at this point.
00:56:12.060 --> 00:56:12.360
Right.
00:56:12.360 --> 00:56:14.340
So that's actually pretty exciting.
00:56:14.540 --> 00:56:14.620
Yeah.
00:56:14.620 --> 00:56:15.660
That's a big change, right?
00:56:15.660 --> 00:56:15.960
Yeah.
00:56:15.960 --> 00:56:16.220
Yeah.
00:56:16.220 --> 00:56:16.540
You're right.
00:56:16.540 --> 00:56:16.880
Yeah.
00:56:16.880 --> 00:56:17.220
Cool.
00:56:17.220 --> 00:56:17.540
All right.
00:56:17.540 --> 00:56:21.360
Well, there's a bunch of articles for people to check out while they're on vacation, got
00:56:21.360 --> 00:56:22.280
some time away from work.
00:56:22.280 --> 00:56:24.940
They don't have to, you know, fill out TPS reports all day.
00:56:24.940 --> 00:56:27.140
Smashed out printer.
00:56:27.140 --> 00:56:27.760
That's right.
00:56:27.760 --> 00:56:28.460
Smashed out printer.
00:56:28.460 --> 00:56:29.540
Awesome.
00:56:29.540 --> 00:56:29.940
All right.
00:56:29.940 --> 00:56:31.340
Well, thanks for being here as always.
00:56:31.340 --> 00:56:31.580
Cool.
00:56:31.580 --> 00:56:31.720
Yeah.
00:56:31.720 --> 00:56:32.480
Thanks for inviting me.
00:56:32.480 --> 00:56:33.000
This is great.
00:56:33.000 --> 00:56:33.380
You're welcome.
00:56:33.380 --> 00:56:35.800
I guess I should ask you the two questions before you go.
00:56:35.800 --> 00:56:40.480
So the two questions are, what editor do you use to write Python code these days?
00:56:40.480 --> 00:56:43.540
So I've started to use Visual Studio Code a lot.
00:56:43.780 --> 00:56:46.260
I use Sublime Text.
00:56:46.260 --> 00:56:46.620
Yeah.
00:56:46.620 --> 00:56:49.380
It's a pretty similar style of editor.
00:56:49.380 --> 00:56:49.840
Very similar.
00:56:49.840 --> 00:56:50.180
Right.
00:56:50.180 --> 00:56:50.520
Yeah.
00:56:50.520 --> 00:56:53.580
What I still love about Sublime is just how fast it is.
00:56:53.580 --> 00:56:58.600
Like there's a noticeable difference in the rendering speed and scrolling around.
00:56:58.600 --> 00:57:05.020
But the Python integration that VS Code has out of the box is really cool.
00:57:05.020 --> 00:57:07.120
It's growing and growing all the things it can do.
00:57:07.120 --> 00:57:12.200
I like it for recording video courses because I can have an integrated shell there.
00:57:12.200 --> 00:57:14.420
I can have a setup that looks really, really nice, I think.
00:57:14.420 --> 00:57:16.780
And so I've been doing that a lot recently.
00:57:16.780 --> 00:57:17.480
And so, yeah.
00:57:17.480 --> 00:57:19.480
Working out of VS Code.
00:57:19.480 --> 00:57:19.760
Yeah.
00:57:19.760 --> 00:57:20.200
Awesome.
00:57:20.740 --> 00:57:22.840
The other question changing for today.
00:57:22.840 --> 00:57:25.160
What's next for RealPython in 2020?
00:57:25.160 --> 00:57:26.420
100 authors?
00:57:26.420 --> 00:57:26.840
Yeah.
00:57:26.840 --> 00:57:27.700
That's a big goal of mine.
00:57:27.700 --> 00:57:31.280
You know, I want to, I would love to have 100 authors published on the site.
00:57:31.280 --> 00:57:33.700
Authors and instructors as a magical number.
00:57:33.700 --> 00:57:37.580
And, you know, maybe we'll crack that 3 million visitors.
00:57:37.720 --> 00:57:39.640
I don't know how many Python developers are out there.
00:57:39.640 --> 00:57:43.340
Well, I suspect after they listen to this episode, it'll probably be 3 million straight up.
00:57:43.340 --> 00:57:44.180
It'll be 10 more.
00:57:44.180 --> 00:57:46.480
For sure.
00:57:46.480 --> 00:57:47.180
It's going to, yeah.
00:57:47.180 --> 00:57:47.740
Awesome.
00:57:47.740 --> 00:57:50.380
Well, best of luck in 2020 and keep up the good work.
00:57:50.380 --> 00:57:51.820
It's a huge resource for everyone.
00:57:51.820 --> 00:57:52.220
Thank you.
00:57:52.220 --> 00:57:53.300
I mean, you know, same to you.
00:57:53.300 --> 00:57:56.280
Like, it's been so cool just becoming friends with you.
00:57:56.280 --> 00:57:59.900
And when we first met, which was, I think, like three years ago.
00:57:59.900 --> 00:58:00.680
Three or four years ago.
00:58:00.680 --> 00:58:01.680
It's quite a while back.
00:58:01.680 --> 00:58:03.880
And just being on this journey here together.
00:58:03.880 --> 00:58:05.120
I really appreciate that.
00:58:05.120 --> 00:58:06.000
Yeah, absolutely.
00:58:06.000 --> 00:58:06.400
Thank you.
00:58:06.400 --> 00:58:06.780
Same to you.
00:58:06.860 --> 00:58:08.080
It's been fun to be on it together.
00:58:08.080 --> 00:58:08.700
Awesome, man.
00:58:08.700 --> 00:58:09.040
All right.
00:58:09.040 --> 00:58:09.780
Well, catch you later.
00:58:09.780 --> 00:58:10.180
Bye.
00:58:10.180 --> 00:58:10.480
Yeah.
00:58:10.480 --> 00:58:10.740
Bye-bye.
00:58:10.740 --> 00:58:14.940
This has been another episode of Talk Python To Me.
00:58:14.940 --> 00:58:17.320
Our guest on this episode was Dan Bader.
00:58:17.320 --> 00:58:20.200
And it's been brought to you by Linode and Brilliant.org.
00:58:20.200 --> 00:58:24.620
Start your next Python project on Linode's state-of-the-art cloud service.
00:58:24.620 --> 00:58:27.780
Just visit talkpython.fm/Linode.
00:58:27.780 --> 00:58:29.140
L-I-N-O-D-E.
00:58:29.140 --> 00:58:32.340
You'll automatically get a $20 credit when you create a new account.
00:58:32.340 --> 00:58:36.000
Brilliant.org encourages you to give the gift
00:58:36.000 --> 00:58:37.380
of critical thought and knowledge.
00:58:37.380 --> 00:58:43.140
Visit talkpython.fm/brilliant and grab a gift subscription to help your loved ones finish
00:58:43.140 --> 00:58:44.740
their day a little smarter this season.
00:58:44.740 --> 00:58:47.100
Want to level up your Python?
00:58:47.100 --> 00:58:51.960
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
00:58:51.960 --> 00:58:57.060
Or if you're looking for something more advanced, check out our new async course that digs into
00:58:57.060 --> 00:59:00.120
all the different types of async programming you can do in Python.
00:59:00.380 --> 00:59:04.080
And of course, if you're interested in more than one of these, be sure to check out our
00:59:04.080 --> 00:59:04.780
Everything Bundle.
00:59:04.780 --> 00:59:06.660
It's like a subscription that never expires.
00:59:06.660 --> 00:59:08.820
Be sure to subscribe to the show.
00:59:08.820 --> 00:59:11.240
Open your favorite podcatcher and search for Python.
00:59:11.240 --> 00:59:12.460
We should be right at the top.
00:59:12.460 --> 00:59:17.280
You can also find the iTunes feed at /itunes, the Google Play feed at /play,
00:59:17.280 --> 00:59:21.440
and the direct RSS feed at /rss on talkpython.fm.
00:59:21.940 --> 00:59:23.520
This is your host, Michael Kennedy.
00:59:23.520 --> 00:59:25.020
Thanks so much for listening.
00:59:25.020 --> 00:59:26.080
I really appreciate it.
00:59:26.080 --> 00:59:27.840
Now get out there and write some Python code.
00:59:27.840 --> 00:59:48.460
I'll see you next time.
00:00:00.001 --> 00:00:05.860
We've come to the end of 2019. Python 2 has just a handful of days before it goes unsupported,
00:00:05.860 --> 00:00:11.500
and I've met up with Dan Bader from realpython.com to look back at the year of Python articles on his
00:00:11.500 --> 00:00:16.920
website. We dive into the details behind 10 of his most important articles from the past year.
00:00:16.920 --> 00:00:22.300
This is Talk Python To Me, episode 244, recorded November 8th, 2019.
00:00:22.300 --> 00:00:40.320
Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the
00:00:40.320 --> 00:00:45.100
ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where
00:00:45.100 --> 00:00:49.620
I'm at mkennedy. Keep up with the show and listen to past episodes at talkpython.fm,
00:00:49.620 --> 00:00:54.360
and follow the show on Twitter via at talkpython. This episode is sponsored by
00:00:54.360 --> 00:00:58.880
linodeandbrilliant.org. Please check out what they're offering during their segments. It really
00:00:58.880 --> 00:01:03.620
helps support the show. Hey there. I want to take just a moment before we get to the interview
00:01:03.620 --> 00:01:10.860
and say thank you. It's the end of 2019. Looking back, it's been a great year for the podcast and
00:01:10.860 --> 00:01:15.260
all the other stuff we're doing, like our courses, and it's been really humbling to get messages from
00:01:15.260 --> 00:01:21.000
all of you about how the podcast is helping you in some way or the benefits you're getting from it.
00:01:21.000 --> 00:01:25.800
And I just want to say thank you for listening because it's a true honor to be able to create
00:01:25.800 --> 00:01:31.280
this podcast for you. It's a lot of work, but it's entirely worth it. It's really, really great,
00:01:31.280 --> 00:01:36.860
and it couldn't be done without you listening and sharing it. So thank you, thank you, thank you.
00:01:36.860 --> 00:01:40.760
Hope your 2019 was great as well. Now let's chat with Dan.
00:01:41.720 --> 00:01:43.380
Dan, welcome back to Talk Python To Me.
00:01:43.380 --> 00:01:44.540
Hey, it's great to be back, man.
00:01:44.540 --> 00:01:47.580
It's great to have you back. It's been a while since you've been on Talk Python, but
00:01:47.580 --> 00:01:50.840
not too long ago since you were on Python Bytes. That was fun.
00:01:50.840 --> 00:01:55.680
Yeah, that's right. We practically just finished recording that. And yeah, it was great with
00:01:55.680 --> 00:01:58.760
Cecil Phillips and yeah, I had some good links that week, I think.
00:01:58.760 --> 00:02:03.720
Yeah, absolutely. So I'm pretty excited about 2019. It was a good year. How was it for you?
00:02:03.720 --> 00:02:07.360
It was a very, very busy year, I would say.
00:02:07.360 --> 00:02:13.580
Yeah, I feel like for you guys, like RealPython has come along a long ways. You've got a lot of
00:02:13.580 --> 00:02:17.720
authors, you've kind of got this process going, you've got your editorial, your editing, and
00:02:17.720 --> 00:02:22.140
overseeing how the content creation is going. And you're making a big difference, I think.
00:02:22.140 --> 00:02:29.400
Thanks. That's good to hear. And yeah, it's just been this incredible year. We're at 75 authors and
00:02:29.400 --> 00:02:33.660
video instructors published on the site now. So I want to get to 100 next year. That would be a nice,
00:02:34.180 --> 00:02:41.900
cool achievement, I think. And we also just recently hit 2 million visitors, like unique visitors or
00:02:41.900 --> 00:02:47.960
readers in a single month, which is kind of this incredible... Let me... I can almost... It totally
00:02:47.960 --> 00:02:53.820
sounds like I'm super bragging here, but I literally can't wrap my brain around that. It's just kind of
00:02:53.820 --> 00:02:59.240
nuts and really cool just to see that growth and how it's resonating and how we're getting really,
00:02:59.240 --> 00:03:00.480
really positive feedback. Yeah.
00:03:00.560 --> 00:03:02.840
Yeah. I think that's really positive and congratulations.
00:03:02.840 --> 00:03:03.400
Thank you.
00:03:03.400 --> 00:03:08.800
Yeah. And I think it speaks one to all the work that you're doing that you talked about. It also speaks
00:03:08.800 --> 00:03:14.440
to just Python's growth in general, right? Like you're riding two curves and they're both going
00:03:14.440 --> 00:03:15.180
in the right direction.
00:03:15.180 --> 00:03:17.420
Yeah, that's true. So how was your 2019?
00:03:17.420 --> 00:03:24.360
My 2019 was amazing. Didn't skip a single episode on any of the podcasts. And I think that's a pretty big
00:03:24.360 --> 00:03:25.400
accomplishment actually.
00:03:25.400 --> 00:03:26.380
That's huge. Yeah.
00:03:26.480 --> 00:03:31.640
Yeah. And released a bunch of classes. I feel like we've covered some important stories
00:03:31.640 --> 00:03:36.900
on the podcast, right? That's one of the things I try to do. We can cover every web framework
00:03:36.900 --> 00:03:40.900
and the person who creates it and that's great and so on. But I really want to highlight that
00:03:40.900 --> 00:03:46.100
Python is not just for web developers or like straight down the middle of the road data scientists.
00:03:46.100 --> 00:03:46.460
Yeah.
00:03:46.600 --> 00:03:54.220
We've had medieval Islamic philosophers and we've had people doing machine learning for particle
00:03:54.220 --> 00:04:00.360
collisions and all sorts of stuff that might have been back in 2018. But those kinds of stories are really
00:04:00.360 --> 00:04:05.400
interesting. I think we had a decent amount of those and I'm really happy to be able to share
00:04:05.400 --> 00:04:07.820
those edge stories that I think are so interesting.
00:04:07.820 --> 00:04:12.400
Yeah. Yeah. I think that's super cool. And then I think a podcast is just such a great format for it as well,
00:04:12.400 --> 00:04:18.680
where somebody can come on the show and join you there and really give the listener a chance to
00:04:18.680 --> 00:04:23.360
understand why this is cool and what the motivation. That's always the most interesting thing for me
00:04:23.360 --> 00:04:27.820
when I listen to your show, figuring out like, okay, why is your guest doing that? Why are they so into
00:04:27.820 --> 00:04:33.080
researching Islamic philosophy with Python, which are two topics that I would have never imagined
00:04:33.080 --> 00:04:37.480
you would combine in some way. And then I listened to the show and I'm like, oh man, it's so cool how
00:04:37.480 --> 00:04:39.720
broad this is, what people are doing with Python.
00:04:39.720 --> 00:04:43.900
Yeah. You listen to the story and it makes perfect sense. You're like, of course you should be doing
00:04:43.900 --> 00:04:48.260
that. And the thing I like about those types of stories is there's a lot of people that think,
00:04:48.260 --> 00:04:52.760
oh, I'm not a programmer or it doesn't make sense for me to do that or whatever. Like,
00:04:52.760 --> 00:04:57.680
I'm just a stock trader. I'm just a biologist. And then you hear that and you're like, all right,
00:04:57.680 --> 00:05:02.440
if somebody can use it for philosophy, thousand year old scrolls, I should be able to find a way to
00:05:02.440 --> 00:05:08.080
make use of this in my much more mainstream type of job. Right. It's like, yeah, obviously there's all
00:05:08.080 --> 00:05:10.700
these amazing things people can do. They just got to be a little creative to do it.
00:05:10.700 --> 00:05:14.240
Yeah. Yeah, absolutely. I feel like we talked about this before, but this whole idea of the dark
00:05:14.240 --> 00:05:19.280
matter developer, someone who doesn't actually really identify as a developer or programmer,
00:05:19.280 --> 00:05:25.440
but there's so many people out there who are practically programmers or they're working with
00:05:25.440 --> 00:05:29.120
code, they're writing code, but they don't really see it that way.
00:05:29.120 --> 00:05:34.740
A big enough part of the community to actually come along and come to the conferences or blog about
00:05:34.740 --> 00:05:37.680
programming. They're probably blogging about something else that they care about. Something
00:05:37.680 --> 00:05:38.180
like that, right?
00:05:38.180 --> 00:05:38.700
Yeah. Yeah.
00:05:38.700 --> 00:05:39.340
Yeah. Sweet.
00:05:39.340 --> 00:05:43.440
Cool. Well, let's talk about what we're going to focus on for this show. So the idea is we're going
00:05:43.440 --> 00:05:49.360
to take 10 of your popular bookicles, book articles, your articles-
00:05:49.360 --> 00:05:50.020
That should be a new one.
00:05:50.020 --> 00:05:50.640
Yeah.
00:05:50.640 --> 00:05:56.620
So we're going to take our near book style on real Python and just pick 10 of them. We're going to
00:05:56.620 --> 00:06:02.480
call it the top 10, but it's not necessarily top 10 by your traffic. It's kind of the ones you wanted
00:06:02.480 --> 00:06:03.540
to highlight from the year, right?
00:06:03.540 --> 00:06:11.400
Yeah. So yeah, I really wanted to give a chance to sample a wider variety of topics because if you go
00:06:11.400 --> 00:06:16.320
purely by traffic numbers, things are just going to get overshadowed by popular terms that people
00:06:16.320 --> 00:06:16.940
search for on Google.
00:06:16.940 --> 00:06:19.920
Look, it's for Django articles or whatever, right? And just because people are searching for that or
00:06:19.920 --> 00:06:20.180
whatever.
00:06:20.180 --> 00:06:26.160
Yeah. And so, yeah. So we kind of assembled a list of 10 articles that we wanted to highlight and then
00:06:26.160 --> 00:06:27.960
go over and then share with you.
00:06:27.960 --> 00:06:28.880
All right. Where are we starting?
00:06:28.880 --> 00:06:34.440
Sweet. So we're starting with an article that's called How to Run Your Python Scripts by
00:06:34.440 --> 00:06:41.700
Leo Danis Pozo Ramos. And it kind of sounds simple, right? You just go-
00:06:41.700 --> 00:06:45.200
Right. Don't you just say python space script.py?
00:06:45.200 --> 00:06:47.920
Yeah. I mean, that's what we do most of the time, right?
00:06:47.920 --> 00:06:48.620
Some of the time, yeah.
00:06:48.620 --> 00:06:56.260
Hit control R or something like that. F5. And this article is cool because it, of course,
00:06:56.360 --> 00:07:02.240
talks about that. But then it goes really, really deep into the behind the scenes and
00:07:02.240 --> 00:07:07.780
what some of the other ways are that you can possibly use to run Python code. So you could
00:07:07.780 --> 00:07:14.580
just load the string from Office Script and then just eval it. Or there's the import lib module
00:07:14.580 --> 00:07:21.180
in Python 3 that you could use. And there's all kinds of other more complex methods where you get
00:07:21.180 --> 00:07:22.960
deeper and deeper into CPython.
00:07:22.960 --> 00:07:27.200
You could do python space dash C and like some code, right?
00:07:27.200 --> 00:07:32.060
You could also do that if you wanted to run a code snippet from the command line. And I just love this
00:07:32.060 --> 00:07:36.840
article because it starts with the really simple and straightforward and like main use case. And then
00:07:36.840 --> 00:07:41.520
it goes deeper and deeper and deeper into all the different alternatives. And you know, what the
00:07:41.520 --> 00:07:48.220
difference is between running a module with Python dash M versus actually just running it by Python
00:07:48.220 --> 00:07:53.760
space from the command, Python space and then the file of the file name and running it from the
00:07:53.760 --> 00:07:57.740
command line. And yeah, for that reason, you know, I wanted to highlight that article.
00:07:57.740 --> 00:08:01.460
Okay. Yeah, that's really cool. And one of the things I like about a couple of the articles that
00:08:01.460 --> 00:08:07.060
we're covering are I look at the title and I go, yeah, I know that. And then I look at the article
00:08:07.060 --> 00:08:11.800
and it's like, I don't know how many words, but it's like, you know, readability suggests this might
00:08:11.800 --> 00:08:15.680
be an over an hour to read this article. I'm like, wait, I thought I just, that was simple and I knew it.
00:08:15.680 --> 00:08:20.620
And you know, when you, whenever I, that kind of makes me think, I'm like, oh, I actually might learn
00:08:20.620 --> 00:08:25.000
something here. If I just pay attention, like this is going deeper or into a different area than,
00:08:25.160 --> 00:08:28.480
because if I thought it was that simple and it's this, then it's clearly I'm missing something.
00:08:28.480 --> 00:08:33.100
Yeah. As the kind of the person running the site and working on the platform there, like I love
00:08:33.100 --> 00:08:37.960
seeing surprises like that because it's always a team of us that's working on the article. So we
00:08:37.960 --> 00:08:43.100
have like multiple review stages and we review the outline and then we review the script and there's
00:08:43.100 --> 00:08:49.500
like a technical review and just seeing these things kind of grow and you'll become a real Python
00:08:49.500 --> 00:08:54.940
article is, I just really enjoy that process and being a part of it. So yeah, this is like a great
00:08:54.940 --> 00:08:59.600
example, I think, of that. Yeah. Yeah. Quite cool. So covers a bunch of stuff and probably something,
00:08:59.600 --> 00:09:04.600
you know, there's definitely a few suggestions in there that I didn't know. All right. What's number
00:09:04.600 --> 00:09:11.580
two? And number two is called 13 Project Ideas for Intermediate Python Developers by Habib
00:09:11.580 --> 00:09:19.780
Shopeyou. And this was born out of a lot of questions that we received over email or Twitter and
00:09:19.780 --> 00:09:25.380
also most recently in our real Python community Slack where people were asking, like, I feel like
00:09:25.380 --> 00:09:30.620
I kind of know how to use Python, but I don't know what I should build. I've learned the language. I know
00:09:30.620 --> 00:09:35.220
loops. I know how to do strings. I create a dictionary, get stuff in and out of it. But what can I actually
00:09:35.220 --> 00:09:37.500
build that like is the next step? Exactly.
00:09:37.760 --> 00:09:42.940
Yeah. Because that's often very challenging. It's not just challenging on like maybe a lack
00:09:42.940 --> 00:09:47.560
of creativity. It's challenging in like, oh, you want to be cool to build Instagram? Like, no,
00:09:47.560 --> 00:09:50.440
it wouldn't be cool to build. It'd be very hard to build. It's like millions of lines of code.
00:09:50.440 --> 00:09:53.980
You know what would be cool to build? As a timer, like, no, it's boring and it's too short. Like,
00:09:53.980 --> 00:09:59.660
what is the right size where it's challenging, but I can reasonably expect to do it if I put in some
00:09:59.660 --> 00:10:03.220
effort? Yeah. And that's a really hard one, right? Like I was back in the day when I learned how to
00:10:03.220 --> 00:10:07.400
code or first started. I mean, I guess you never really stopped learning how to program.
00:10:07.400 --> 00:10:12.140
I was in these like game development forums and there was every single week there was like
00:10:12.140 --> 00:10:17.000
a new person joining and they were like, I want to build this MMORPG or like, I want to build this
00:10:17.000 --> 00:10:21.200
like massive thing. And so everybody was working on these like massive projects that never really
00:10:21.200 --> 00:10:25.980
went anywhere. And I think that could be really, really frustrating. And so my answer to that question,
00:10:25.980 --> 00:10:29.980
you know, what should I build as an intermediate developer was usually like, just pick whatever,
00:10:29.980 --> 00:10:34.820
you know, just take a command line app that you use and try to emulate, like try to write your own
00:10:34.820 --> 00:10:39.040
version of it. But the problem is that doesn't really work for some learners, for some students.
00:10:39.040 --> 00:10:42.860
And so we wanted to give them a list with ideas, you know, here's some things that we think you could
00:10:42.860 --> 00:10:47.880
probably pull off. You have a fighting chance of actually like building this app, right? And it's
00:10:47.880 --> 00:10:52.680
not going to be a world of Warcraft, but it's going to be a cool like alarm tool or a little file
00:10:52.680 --> 00:10:58.160
manager or a little note-taking application. Yeah. Give us a sense of some of the ideas you got there.
00:10:58.160 --> 00:10:59.720
Yeah. So the ones that I just mentioned.
00:10:59.720 --> 00:11:08.680
Yeah, exactly. So MP3 player, URL shortener, file rename. Yeah. That's really nice.
00:11:08.680 --> 00:11:12.840
Contact book, I think is also something interesting where, you know, there's different ways you could
00:11:12.840 --> 00:11:18.180
store the data could just be like a little, yeah, like an address book where maybe you ask, you know,
00:11:18.180 --> 00:11:23.800
it could be as simple as just storing a dictionary to a text file, or then you could get progressively
00:11:23.800 --> 00:11:26.920
more interesting there and have a little database maybe.
00:11:26.920 --> 00:11:30.880
You could use SQLite and then you could start using SQLAlchemy because, you know, you don't
00:11:30.880 --> 00:11:35.100
want to be writing inline SQL and then, you know, become little Bobby tables.
00:11:35.100 --> 00:11:39.600
Yeah, that's right. Well, you know, someone could take you a great free MongoDB course.
00:11:39.920 --> 00:11:42.360
Yeah, exactly. Yeah. They could do a MongoDB back one.
00:11:42.360 --> 00:11:43.000
All kinds of options there.
00:11:43.000 --> 00:11:46.480
Yeah. They could totally like level these up. They could put them online, all kinds of cool
00:11:46.480 --> 00:11:50.680
stuff. Yeah. So I like it. And you got it broken down to web, GUI and command line. That's pretty
00:11:50.680 --> 00:11:50.940
good break.
00:11:50.940 --> 00:11:54.660
Yeah, that's right. Yeah. We try to give like a high level overview and then depending on what
00:11:54.660 --> 00:11:57.480
you're interested in, you could pick the right project for you.
00:11:57.480 --> 00:11:59.160
Yeah. Super. All right. What's next?
00:11:59.160 --> 00:12:05.100
All right. So I think we are at article number three. And what I wanted to highlight there is
00:12:05.100 --> 00:12:11.400
the article is called Three Ways of Storing and Accessing Lots of Images in Python by Rebecca Stone.
00:12:11.400 --> 00:12:16.360
And I think this article is cool because, again, it's something that I never really thought about
00:12:16.360 --> 00:12:21.060
before. You know, I was like, OK, you know, my Django app uses a bunch of static images.
00:12:21.060 --> 00:12:22.700
There's just a folder in there.
00:12:22.700 --> 00:12:25.540
Right, right. That's slash static slash IMG or something, right?
00:12:25.540 --> 00:12:31.200
Yeah. But what if that maybe doesn't work so great anymore? I think you're storing a
00:12:31.200 --> 00:12:36.060
massive amount of images. You know, you have some, I don't know, some robot, some probe that's going
00:12:36.060 --> 00:12:40.620
to Mars and you have lots, you have like terabytes of images. And where are you going to store them?
00:12:40.620 --> 00:12:42.020
How are you going to make this manageable?
00:12:42.020 --> 00:12:48.740
Right. Are you going to create some kind of like automated IoT doorbell that always snapshots,
00:12:48.740 --> 00:12:49.580
whatever's close, right?
00:12:49.580 --> 00:12:54.020
Yeah. And if your house gets broken in a lot, eventually you have too many images and you got
00:12:54.020 --> 00:12:55.680
to figure out what to do with them.
00:12:55.680 --> 00:12:58.180
That's right. Why are all these people at my house? You're killing my storage.
00:12:58.180 --> 00:12:59.720
All right. So what are some of the suggestions?
00:12:59.720 --> 00:13:05.520
Yeah. So it goes, the article goes into three techniques there. So the first one is, you know,
00:13:05.520 --> 00:13:10.900
just like store them on disk as .png files or, you know, JPEG or what have you. And then the
00:13:10.900 --> 00:13:16.660
second option is using a memory mapped database called LMDB. And the third option is using a
00:13:16.660 --> 00:13:27.140
hierarchical hierarchical data format like HDF5. And the latter two, I'd never really heard about before.
00:13:27.140 --> 00:13:34.140
But it turns out, of course, that there is a lot of Python tooling available for these things.
00:13:34.800 --> 00:13:39.980
And so they provide a number of interesting features. So for example, there's a compression
00:13:39.980 --> 00:13:46.440
that you could use. So to potentially limit your disk usage. And there's just lots of good tooling,
00:13:46.440 --> 00:13:50.260
if that's a problem that you're facing, that people can use with Python.
00:13:50.260 --> 00:13:55.440
Yeah, this is interesting. Like I'd never heard of LMDB, but apparently it's lightning memory mapped
00:13:55.440 --> 00:13:57.340
databases, which sounds fascinating.
00:13:57.340 --> 00:14:01.560
It sounds, yeah. It's like, I should definitely check that out. Find a use case for that. Cause that
00:14:01.560 --> 00:14:01.980
sounds cool.
00:14:01.980 --> 00:14:05.220
Yeah. You got to build that, that magical doorbell robot.
00:14:05.220 --> 00:14:10.140
Right. Maybe selfies for robots or something. They just do it all day long. All right. Awesome.
00:14:10.140 --> 00:14:12.100
All right. So what's number four?
00:14:12.100 --> 00:14:17.420
Number four is called Speed Up Your Python Program with Concurrency by Jim Anderson.
00:14:17.420 --> 00:14:20.180
Oh, this is one that definitely, definitely resonates with me.
00:14:20.180 --> 00:14:27.560
It's, yeah, you have a lot of great material on asyncio and working with parallelism and concurrency
00:14:27.560 --> 00:14:36.040
with Python. And the idea for this article was to give the reader an overview of what different
00:14:36.040 --> 00:14:41.860
types of concurrency that are out there. And what does it mean if a program is CPU bound versus IO bound
00:14:41.860 --> 00:14:47.940
and which options make sense using, you know, when should you use threading versus a multi-processing
00:14:47.940 --> 00:14:54.260
or asyncio. And we also added an interactive quiz to it. So that, you know, if you're reading this,
00:14:54.260 --> 00:14:57.540
you can really make sure, okay, I actually understood these concepts because they're pretty
00:14:57.540 --> 00:14:59.280
difficult to take in the first time.
00:14:59.280 --> 00:15:03.020
Yeah. That's the kind of thing that just needs to wash over you several times until you're like,
00:15:03.020 --> 00:15:05.480
all right, I'm starting, I'm starting to get the feel of this thing.
00:15:05.480 --> 00:15:09.840
Yeah. Get burned by it a couple of times and you're like, oh no, I got to re-architect this again.
00:15:09.840 --> 00:15:14.620
Exactly. And I think this is important in Python because I think Python's concurrency story
00:15:14.620 --> 00:15:21.500
is both amazing, but non-obvious in some ways. And what I mean by that is a lot of programming
00:15:21.500 --> 00:15:27.560
languages, you can leverage computational concurrency by using just threads, right? Because I got, you
00:15:27.560 --> 00:15:32.100
know, this thing believes it has 12 threads in my MacBook here. It has six hyper-threaded cores,
00:15:32.100 --> 00:15:37.560
right? So if I were to like write a single-threaded program, it'll get like eight or 9% CPU usage
00:15:37.560 --> 00:15:41.860
and that's it. So if I want to make that go faster on a lot of languages, C++, C#, whatever,
00:15:41.860 --> 00:15:45.680
I can just create a bunch of threads and it can start running on all of those different threads.
00:15:45.680 --> 00:15:50.840
But in Python, we have the gill, so it doesn't work, right? And that's, I think, actually caused a lot
00:15:50.840 --> 00:15:55.400
of challenges because people say, well, that means Python's concurrency is broken. It's not broken.
00:15:55.400 --> 00:15:59.420
It just needs a clearer mental model of when to apply each technique.
00:15:59.420 --> 00:16:01.920
Yeah. It's kind of like a manual gear shift, right?
00:16:01.920 --> 00:16:02.400
Yeah. Yeah.
00:16:02.400 --> 00:16:04.920
It's not broken, but the car is also not going to go.
00:16:04.920 --> 00:16:09.640
It drives in the day, but it won't drive at night. Put it in night mode. It won't go.
00:16:09.640 --> 00:16:10.460
Put it in N.
00:16:11.660 --> 00:16:17.400
Yeah, exactly. So for example, if it's IO bound, probably what you want to do is something
00:16:17.400 --> 00:16:22.840
to do with asyncio, right? But if it's computational, you really need to do, at least for the moment,
00:16:22.840 --> 00:16:24.220
something with multiprocessing.
00:16:24.220 --> 00:16:24.340
Yeah.
00:16:24.340 --> 00:16:26.000
And so it compares those types of things, huh?
00:16:26.000 --> 00:16:30.700
Yeah, exactly. And like I said, you know, we have this quiz at the end that you can take
00:16:30.700 --> 00:16:35.120
and then really make sure, okay, I understand what the differences are between these concurrency
00:16:35.120 --> 00:16:35.460
models.
00:16:35.460 --> 00:16:41.780
This portion of Talk Python To Me is brought to you by Linode. Whether you're working on a personal
00:16:41.780 --> 00:16:47.280
project or managing your enterprise's infrastructure, Linode has the pricing, support, and scale that you
00:16:47.280 --> 00:16:52.320
need to take your project to the next level. With 11 data centers worldwide, including their newest
00:16:52.320 --> 00:16:59.100
data center in Sydney, Australia, enterprise-grade hardware, S3-compatible storage, and the next-generation
00:16:59.100 --> 00:17:03.820
network, Linode delivers the performance that you expect at a price that you don't.
00:17:03.820 --> 00:17:10.140
Get started on Linode today with a $20 credit and you get access to native SSD storage, a 40-gigabit
00:17:10.140 --> 00:17:15.380
network, industry-leading processors, their revamped cloud manager at cloud.linode.com,
00:17:15.380 --> 00:17:22.180
root access to your server, along with their newest API and a Python CLI. Just visit talkpython.fm
00:17:22.180 --> 00:17:27.380
slash Linode when creating a new Linode account and you'll automatically get $20 credit for your
00:17:27.380 --> 00:17:32.620
next project. Oh, and one last thing. They're hiring. Go to linode.com slash careers to find
00:17:32.620 --> 00:17:34.420
out more. Let them know that we sent you.
00:17:34.420 --> 00:17:37.660
Number five.
00:17:37.660 --> 00:17:43.560
All right. Number five. Build a recommendation engine with collaborative filtering by Abinaf
00:17:43.560 --> 00:17:47.120
Aitzeria. And what do you think this is?
00:17:47.120 --> 00:17:53.220
I'm reading a real Python article and it says, you might also like these other three or something
00:17:53.220 --> 00:17:57.360
like that or talk Python course. You might also like this one, right? It's a good follow-on
00:17:57.360 --> 00:18:01.500
for various reasons, right? People who took this course usually took that one next or people who
00:18:01.500 --> 00:18:05.320
read this article also like shared that other article or something.
00:18:05.320 --> 00:18:10.340
Yeah, exactly. It's about building a recommender or recommendation engines like you would have on,
00:18:10.340 --> 00:18:16.620
you know, pretty much any larger website like Netflix or Amazon. They're all recommending you
00:18:16.620 --> 00:18:22.080
products or movies that you might enjoy based on what you already watched. And a lot of times what
00:18:22.080 --> 00:18:28.020
they do is they look at, kind of build a profile of the things that you watched and then kind of
00:18:28.020 --> 00:18:33.220
finding similar users, other users on the platform that watched those movies and enjoyed them. And
00:18:33.220 --> 00:18:37.040
then based on that, trying to figure out, okay, what did these other people also watch and enjoy?
00:18:37.040 --> 00:18:40.800
And maybe we can recommend that back to you and then hopefully you'll have a good time on the
00:18:40.800 --> 00:18:41.100
platform.
00:18:41.100 --> 00:18:45.020
Yeah, that sounds really cool. It sounds like very relevant to data scientists and there's probably
00:18:45.020 --> 00:18:47.060
a lot of data science algorithms in there, huh?
00:18:47.060 --> 00:18:51.280
Yeah, absolutely. I think there's some cool stuff happening there and there's some matrix math.
00:18:51.940 --> 00:18:56.300
What I like about this article that I really like how it turned out from like a typesetting
00:18:56.300 --> 00:19:01.340
perspective. So that was like a really big aspect of kind of building the new real Python
00:19:01.340 --> 00:19:07.440
CMS and hosting platform and built on Python 3, Django 2 and all the good things. It was a lot of fun
00:19:07.440 --> 00:19:12.360
building it and working on it. And I mean, I'm still working on it. And I think this is just a cool
00:19:12.360 --> 00:19:16.720
showcase for that also, you know, where you get some graphs in there, you get some interactive,
00:19:16.940 --> 00:19:21.640
or you get some code snippets that you can copy and paste and you get some math typesetting there.
00:19:21.640 --> 00:19:28.480
And I think that makes it very engaging to the reader as well. And yeah, and it's just a cool
00:19:28.480 --> 00:19:33.360
topic. Like I'm just fascinated by those things, you know, how you can use the wisdom of crowds or
00:19:33.360 --> 00:19:36.360
whatever that way. You know, you could say like, well, we have enough people using the platform,
00:19:36.360 --> 00:19:39.960
you have enough people watching Netflix. And then all of a sudden I can get these amazing
00:19:40.340 --> 00:19:42.500
recommendations for other things I would have never thought about watching.
00:19:42.500 --> 00:19:45.560
Yeah. You help it make it better for other people without even knowing it, right?
00:19:45.560 --> 00:19:45.860
Yeah.
00:19:45.860 --> 00:19:50.740
Your actions are there and used for good. Yeah. So it talks about things like K nearest neighbors
00:19:50.740 --> 00:19:55.100
and probably the fundamental algorithm there that's being used, right?
00:19:55.100 --> 00:20:00.800
Yeah. I believe it's for this particular recommendation system technique called collaborative
00:20:00.800 --> 00:20:06.040
filtering. But there's also other approaches that I can't really speak intelligently about.
00:20:06.040 --> 00:20:11.380
Yeah, sure. There's even some cool recommendations like the surprise recommender system, which is a
00:20:11.380 --> 00:20:17.400
Python scikit-learn extension, right? So you can install scikit-surprise.
00:20:17.400 --> 00:20:19.780
It's a cool name for recommender system.
00:20:19.780 --> 00:20:23.940
That's a great recommender, right? Like surprise, we actually can recommend something useful. This is
00:20:23.940 --> 00:20:26.060
not like wasted space here. Yeah.
00:20:26.060 --> 00:20:31.040
Cool. Yeah. So if people are interested, they can check that out. And also I noticed it's kind of
00:20:31.040 --> 00:20:35.460
got this bimodal way of working which says, well, if you want to use pip, here's how you do it. If you want to use
00:20:35.460 --> 00:20:40.440
Anaconda, here's how you use that as well, right? So this one seems like there'd be a lot of folks
00:20:40.440 --> 00:20:44.240
using Anaconda as their Python distribution to work on this.
00:20:44.240 --> 00:20:50.140
Yeah. I think if in the data science space, Conda seems to be quite popular. And so typically we kind
00:20:50.140 --> 00:20:54.500
of standardize like for the articles, we standardize on just using pip because that's kind of the lowest
00:20:54.500 --> 00:20:55.980
common denominator. Yeah.
00:20:55.980 --> 00:21:02.020
But in this case, you know, we felt like it makes sense to be closer to where the target audience might
00:21:02.020 --> 00:21:04.360
be there. Right, right. Take it to the data scientists, right?
00:21:04.880 --> 00:21:06.120
Yeah.
00:21:06.120 --> 00:21:08.460
That's really cool. So I love it. It's a good one.
00:21:08.460 --> 00:21:11.380
Number six on our list here.
00:21:11.380 --> 00:21:16.000
Right. So this one might be a bit surprising, but it is called Your Guide to the Python Print
00:21:16.000 --> 00:21:16.540
Function.
00:21:16.540 --> 00:21:20.780
And this is the one that I was talking about when I thought like, okay, I'd know this thing.
00:21:20.780 --> 00:21:21.360
Yeah.
00:21:21.360 --> 00:21:23.060
Like, wait a minute, maybe I don't know this thing.
00:21:23.140 --> 00:21:33.360
So this is more like a book about the Python print function by Bartosz Zaszinski. And this is just this
00:21:33.360 --> 00:21:39.900
incredible deep dive into the print function slash print statement in Python 2. Because again, you know,
00:21:39.900 --> 00:21:43.540
would think, okay, maybe this is maybe a paragraph or two about what you can do with the print function.
00:21:43.540 --> 00:21:45.340
You know, you can pass some arguments to it.
00:21:45.340 --> 00:21:47.120
It requires parentheses now. It didn't used to.
00:21:47.320 --> 00:21:52.380
Exactly. Right. Like what else is there to say? And then it goes really, really deep into the
00:21:52.380 --> 00:21:58.820
history of the print function and some common use cases that maybe you might not associate with the
00:21:58.820 --> 00:22:03.140
print function directly upon first glance. You know, for example, well, how can you build a cool
00:22:03.140 --> 00:22:10.120
console user interface? How can you do colors in the terminal? And how can you pretty print if you
00:22:10.120 --> 00:22:14.320
have a nested data structure, like some JSON that you parsed into dictionary? How can you make sure
00:22:14.320 --> 00:22:20.620
it actually looks good when you print it out to the console or some debug window? And so it's not
00:22:20.620 --> 00:22:25.820
just purely about the print function, but all the kinds of different best practices and ways you can
00:22:25.820 --> 00:22:28.000
make printing better in your Python programs.
00:22:28.000 --> 00:22:33.600
Yeah, that's cool. No one wants to try to use a minified dictionary for debugging.
00:22:33.600 --> 00:22:39.400
Nope. That's very annoying. I usually take those and then paste them into the black online
00:22:39.400 --> 00:22:45.020
format. I get like a nicer representation. Yeah. Yeah. Yeah. So we cover some of the things I
00:22:45.020 --> 00:22:50.260
think are actually not super obvious to new folks coming from the language, right? Like
00:22:50.260 --> 00:22:55.660
that's right. If you come from other languages, you might not know that you can actually use a
00:22:55.660 --> 00:23:01.400
keyword argument to set the end to be instead of a backslash end to be like a comma and print on one
00:23:01.400 --> 00:23:06.120
line with a bunch of commas or something like that or the buffering, right? If I'm trying to do
00:23:06.120 --> 00:23:11.140
something computational and print out as the computation is happening, a lot of times that
00:23:11.140 --> 00:23:15.520
can get buffered up and then it like all shoots out at once. Or, you know, like if you're like
00:23:15.520 --> 00:23:19.880
delaying waiting on something, you want to actually see all the output. Like there's a bunch of little
00:23:19.880 --> 00:23:24.060
tips like that in there, right? Yeah. Yeah. And like with everything, it's there's a deep rabbit hole.
00:23:24.580 --> 00:23:30.180
Yeah. Down the rabbit hole you go, right? Yeah. I love this kind of article where you think, okay,
00:23:30.180 --> 00:23:34.560
we're going to scratch the surface here a little bit and then we're done. And then there's all kinds
00:23:34.560 --> 00:23:40.420
of interesting other things you could do or just learn why certain things work the way they do. You
00:23:40.420 --> 00:23:48.200
know, ANSI or ANSI escape sequences for making the making colors in the terminal. When you read about
00:23:48.200 --> 00:23:52.800
them, they kind of looks like this incredibly confusing format. And then you learn a bit more
00:23:52.800 --> 00:23:57.740
about the history and you know how it relates to the sort of these old school terminals of the old
00:23:57.740 --> 00:24:03.460
like mainframe computers and how, you know, it's just a format that has grown over decades. And
00:24:03.460 --> 00:24:07.720
well, sure, we could all, you know, throw it away and maybe engineer something from scratch. But it's kind
00:24:07.720 --> 00:24:12.300
of cool to understand, you know, if I'm, if I don't know, you know, boot up my Windows computer or
00:24:12.300 --> 00:24:18.620
MacBook in, in 2020, why it's still supporting that stuff and how it goes back, you know, 50 years.
00:24:18.620 --> 00:24:23.640
Yeah. Well, another thing that I think makes a night and day difference for these simple little
00:24:23.640 --> 00:24:29.780
command line apps is color. More of those should use color, right? If you're saying in the help output,
00:24:29.780 --> 00:24:34.320
it would be great to show the required arguments is like one color and the optional ones is another.
00:24:34.480 --> 00:24:40.500
And it's incredibly easy. But if you don't know to do it, or you think it's hard, or it's hard to do
00:24:40.500 --> 00:24:42.120
cross platform or whatever, then you won't.
00:24:42.120 --> 00:24:47.680
Yeah. Yeah. Oh, speaking of color there in the terminal, one of my favorite tools is the B Python
00:24:47.680 --> 00:24:48.200
REPL.
00:24:48.200 --> 00:24:49.200
B Python?
00:24:49.200 --> 00:24:56.520
B Python. So the letter B, and then Python, one word. It's a Python interpreter, like a Python, not an
00:24:56.520 --> 00:25:01.240
interpreter, but a REPL environment. That is just like the when you start Python from a command line,
00:25:01.300 --> 00:25:05.840
you get your little prompt and you can type a Python code into it and run it. But it does
00:25:05.840 --> 00:25:09.060
syntax highlighting. So it'll give you beautiful colors in the terminal.
00:25:09.060 --> 00:25:09.440
Nice.
00:25:09.440 --> 00:25:12.340
And it also does autocomplete, which is kind of cool.
00:25:12.340 --> 00:25:18.140
So we use that all the time in our video courses and examples. And people always ask like,
00:25:18.140 --> 00:25:21.080
oh, what's that? What's that tool? I want to use that too. And it's great. Like,
00:25:21.080 --> 00:25:23.040
like the color really adds a lot of value.
00:25:23.040 --> 00:25:27.620
It adds a lot. Yeah. I maybe, I think I've heard of B Python. I haven't used it. I'm all about the
00:25:27.620 --> 00:25:29.340
PT Python. Are you familiar with that?
00:25:29.340 --> 00:25:29.980
Oh, that's great too. Yep.
00:25:29.980 --> 00:25:36.480
Yeah. It's like Emacs in the REPL kind of. Yeah. It takes me back to my Emacs days. So last thing,
00:25:36.480 --> 00:25:41.560
like we go on and on about this, like incredibly for a really long time about printing. But there's
00:25:41.560 --> 00:25:45.340
one thing that's in here. I think that's, that's pretty interesting that they talk about that I guess
00:25:45.340 --> 00:25:50.620
also surprised me. I didn't really think about it is mocking the print function for unit tests.
00:25:50.620 --> 00:25:56.260
Yeah. That's a kind of a surprise, right? But it's, it's actually a pretty annoying problem. If you,
00:25:56.260 --> 00:26:00.140
if you want to write tests for a program where in the test, you actually want to make sure it's
00:26:00.140 --> 00:26:04.400
printing the right stuff. Well, how do you do it? You know, how can you actually redirect that output
00:26:04.400 --> 00:26:09.520
into some kind of buffer so you can inspect it and say, okay, we got the output that we wanted.
00:26:09.520 --> 00:26:14.620
I called this and it said, enter this or whatever, right? Like the prompt that we were expecting or
00:26:14.620 --> 00:26:20.160
something. Yeah. Yeah. Yeah. Yeah. Pretty cool. All right. Well, let's move on because it is the
00:26:20.160 --> 00:26:24.800
print function, but it is actually really, really interesting. And what are we up to number?
00:26:24.800 --> 00:26:30.760
I am trying to check. I think number seven, this is number seven. Yes. Number seven. Yeah. And it
00:26:30.760 --> 00:26:36.620
goes right along to number eight in a sense. So how to write beautiful Python code with PEP 8.
00:26:36.620 --> 00:26:44.120
Yeah. So this is a cool article by Jasmine Feiner and it's about the PEP 8 style guide and sort of
00:26:44.120 --> 00:26:51.980
a beginner friendly intro to PEP 8, why it exists, how it can help you format your code in a way that
00:26:51.980 --> 00:26:58.740
other Python developers will expect and appreciate. And I think it's, it's a really good one because,
00:26:58.740 --> 00:27:04.040
you know, it breaks it. Like if, when you read the actual PEP 8 can be feedback that I heard in the
00:27:04.040 --> 00:27:08.940
past, it's just very, very overwhelming to take it all in and take all the examples in. So we try to
00:27:08.940 --> 00:27:15.980
break it down and give you a good overview and then point you to the original PEP so you can do the deep
00:27:15.980 --> 00:27:20.240
dive. Yeah. It's really cool. And you know, it's one of those things that's really important that,
00:27:20.240 --> 00:27:28.340
so you look like you belong, right? If you start doing stuff that is, you know, Java style or C#
00:27:28.340 --> 00:27:34.020
style and someone says, yeah, I'm interviewing for a Python job. And here, let me write a little
00:27:34.020 --> 00:27:40.260
code for you and you start using like camel case method names or something like that. You're like,
00:27:40.260 --> 00:27:45.200
not so sure you're a Python developer. You don't look like you're from around here, right?
00:27:45.200 --> 00:27:48.500
Yeah. First impressions matter, I guess.
00:27:48.500 --> 00:27:52.620
Yeah. And you know, once you know the conventions, some of those conventions have meaning,
00:27:52.620 --> 00:27:59.780
right? Like the underscore has a certain meaning and things like that. And so it's not implicitly
00:27:59.780 --> 00:28:04.000
obvious from that thing that what the meaning is. But once you study it, then you get to know,
00:28:04.000 --> 00:28:04.180
right?
00:28:04.180 --> 00:28:09.580
Yeah. Yeah. I'm actually, I wanted to ask you what's, is your talk Python, is the code for the
00:28:09.580 --> 00:28:11.560
talk Python platform? Is it PEP 8 compliant?
00:28:11.560 --> 00:28:12.960
Is it PEP 8 compliant?
00:28:12.960 --> 00:28:18.700
It's both for the platform it is, I would say PEP 8 compliant. And I try to do that in the courses.
00:28:18.700 --> 00:28:24.660
Probably the way I do that most is just running, like working on everything in PyCharm and PyCharm
00:28:24.660 --> 00:28:29.100
will highlight stuff and make it obviously, it'll like, as you type a highlight, it'll go, no,
00:28:29.100 --> 00:28:33.020
no, no, no. There's something clearly wrong. Like you don't have an underscore, you have camel case
00:28:33.020 --> 00:28:38.880
on a variable name. Stop doing that. Right. And so, yeah, I don't run anything like black across
00:28:38.880 --> 00:28:44.520
the whole thing. The only thing I've run entirely across the whole code base, not across the courses
00:28:44.520 --> 00:28:49.100
because it's recorded. So it'd be weird to change it. But in terms of the platform, I've used Flint.
00:28:49.100 --> 00:28:50.160
Are you familiar with Flint?
00:28:50.160 --> 00:28:54.360
I feel like I heard about it. Is this another auto format?
00:28:54.360 --> 00:29:00.440
It has, it's a very special tool, but I love it. What it does is it will take all the various string
00:29:00.440 --> 00:29:08.600
formatting styles of working with strings. So percent, value value, or the format, something
00:29:08.600 --> 00:29:10.920
or other, and so on. And it turns on all the f-strings.
00:29:10.920 --> 00:29:11.660
Oh, that's cool.
00:29:11.660 --> 00:29:14.060
Yeah. It'll just rewrite your code, like rewrite all your f-strings.
00:29:14.060 --> 00:29:17.940
I know a certain core Python developer who would love that. Marietta.
00:29:17.940 --> 00:29:20.080
She does all these awesome stickers.
00:29:20.080 --> 00:29:26.620
Yeah, yeah. Yes, man. Yeah. So I ran it. In the early days, it had a couple of bugs when you were doing
00:29:26.620 --> 00:29:34.400
numerical formatting, like this number, comma, colon, comma, like 0.2F. Like that would get freaked out.
00:29:34.400 --> 00:29:37.580
But yeah, like after a couple of iterations, it's really quite good.
00:29:37.580 --> 00:29:40.400
Oh, that's cool. I think, yeah, I got to run that. That's great.
00:29:40.400 --> 00:29:44.720
Yeah. So I just ran it against like 20,000 lines of code across the training site and the Talk Python
00:29:44.720 --> 00:29:49.300
and Python Bytes websites. And I think there was like maybe one mistake. So I just,
00:29:49.420 --> 00:29:52.980
I looked at the diff before I checked them all in and just said, actually this, you know,
00:29:52.980 --> 00:29:55.340
one out of a thousand, there's this mistake. But yeah, yeah.
00:29:55.340 --> 00:29:57.640
I think actually those are probably pretty much gone. But yeah, anyway,
00:29:57.640 --> 00:30:00.820
and it's not PEP 8, but it's a sort of a continuation.
00:30:00.820 --> 00:30:05.940
Yeah. And I think with this stuff, I feel like we've got to be clear, like it can often be ambiguous,
00:30:05.940 --> 00:30:09.700
right? Like any, any sort of code style guide, like PEP 8 or what have you, you know,
00:30:09.700 --> 00:30:15.540
in other languages, it's usually not at the end of the day, like naming is a big part of a
00:30:15.540 --> 00:30:18.180
developer's job, I think, you know, and in picking names that are
00:30:18.760 --> 00:30:21.440
actually communicating the intent well and other people can understand.
00:30:21.440 --> 00:30:26.380
And so it's, it's, it's not going to solve that problem because, well, even though if,
00:30:26.380 --> 00:30:30.280
you know, if you're following PEP 8 to a T and you're using all the upper and lowercase letters
00:30:30.280 --> 00:30:35.460
in the, in the right way, and your naming isn't, just doesn't make sense, then that's also not
00:30:35.460 --> 00:30:38.160
going to be great. So it's, yeah, another example might be struggle.
00:30:38.480 --> 00:30:43.160
Yeah. You're doing a list comprehension and it's all on one line, right? It's got the,
00:30:43.160 --> 00:30:49.980
you know, and for N and such and such, if N such and such. And it happens to be 79 line characters
00:30:49.980 --> 00:30:54.880
long. So it's on column 79. It's fine. You don't need to wrap it, but it's like super hard to
00:30:54.880 --> 00:31:00.180
understand. It would make sense to have that three lines, the select value, the loop, the,
00:31:00.180 --> 00:31:04.340
the collection is going through and the test, right? It would be much better. But PEP 8 doesn't say,
00:31:04.340 --> 00:31:10.220
well, if it's 79 lines and complicated, it should be broken up. But 80 lines is, you know,
00:31:10.220 --> 00:31:13.940
like the hard limit and things like that, right? Yeah. Yeah. And so we've got to think beyond it.
00:31:13.940 --> 00:31:17.780
Are you following the 79 characters limit in your code basis?
00:31:17.780 --> 00:31:24.280
Do I follow? Sometimes. There's a few times where I don't like, so if I have a, a raw string or
00:31:24.280 --> 00:31:28.700
multi-line, not raw string, a multi-line string where you do triple quote, then like there's a bunch of
00:31:28.700 --> 00:31:33.760
stuff and then triple quote to close it. I don't know of a way to not do more than 80 lines. If what needs to
00:31:33.760 --> 00:31:37.700
be in the string is more than, or 80 columns, but he would still complain to me like, oh no,
00:31:37.700 --> 00:31:41.620
this line is 120. I'm like, yeah, but you show me how to fix it and we'll have a conversation,
00:31:41.620 --> 00:31:45.240
but I can't fix this, right? Yeah. Without completely going, you know what, we're going to have a string
00:31:45.240 --> 00:31:51.800
concatenation like to nobody's end rather than this multi-line string. So there's a few edge cases,
00:31:51.800 --> 00:31:55.880
but I try to. Yeah, me too. Like ever since I started using black, you're like, black's going to change
00:31:55.880 --> 00:32:00.400
it anyway. I think you can tell it like to use a different line length limit. Like I feel like that's,
00:32:00.400 --> 00:32:05.140
that's always something that comes up where it's like a kind of controversial topic where should
00:32:05.140 --> 00:32:10.000
you follow the 79 character limit is even another, there's like a 72 character limit recommendation
00:32:10.000 --> 00:32:15.360
for doc strings. Like I try to follow that as well. I have like my, you know, these like a little,
00:32:15.360 --> 00:32:19.520
little gutter margin set up in the editor. So yeah, exactly. That's cool. But then at the,
00:32:19.520 --> 00:32:22.760
sometimes I'm thinking, okay, but wouldn't it be nice just to go a hundred characters or longer?
00:32:22.760 --> 00:32:25.960
So I think, I think like whatever number of people pick, as long as you're consistent,
00:32:25.960 --> 00:32:28.780
it's, it's probably a good thing. Yeah. It's somewhat contextual.
00:32:28.780 --> 00:32:35.520
This portion of Talk Python To Me is brought to you by Brilliant.org. Let me knock something off
00:32:35.520 --> 00:32:41.100
your holiday to-do list. Gifts. Spread the love to your loved ones by gifting them Brilliant.
00:32:41.100 --> 00:32:46.100
This really excites me because it's such a fun way to nurture curiosity, build confidence,
00:32:46.100 --> 00:32:50.920
and develop problem-solving skills crucial to school, job interviews, or to their career.
00:32:50.920 --> 00:32:55.600
Brilliant's thought-provoking content breaks up the complexities into bite-sized,
00:32:55.840 --> 00:33:01.620
understandable chunks that will lead them from curiosity to mastery. Go to talkpython.fm
00:33:01.620 --> 00:33:06.640
slash brilliant and grab a gift subscription to help your loved ones finish their day a little
00:33:06.640 --> 00:33:11.460
smarter this season. That's talkpython.fm/brilliant, or just click the link in the show notes.
00:33:13.620 --> 00:33:21.660
We talked about Pep 8. Now how about Article 8? Article 8 is about the Python Lambda function. So it's called
00:33:21.660 --> 00:33:28.780
How to Use Python Lambda Functions by Andre Bourgo. And yeah, I wanted to highlight this one because
00:33:28.780 --> 00:33:37.120
Lambdas and Python are a topic that can be challenging. I think it's something that a lot of times you don't
00:33:37.120 --> 00:33:41.680
really have to, you don't really work with. And so you don't get a lot of experience working with it.
00:33:41.680 --> 00:33:45.800
And then when there might be a situation where it's actually useful, for example, if you want to
00:33:45.800 --> 00:33:50.660
sort a list or something sorted by a custom key, then if you don't know about Lambdas,
00:33:50.660 --> 00:33:52.720
it's going to be a frustrating experience.
00:33:52.720 --> 00:33:56.780
Right, right. Like I got to write this other function and that's kind of weird. But yeah,
00:33:56.780 --> 00:34:01.420
so they're one of the things that when you learn them, you're like, man, that is cool. I can't
00:34:01.420 --> 00:34:06.220
believe I can think of immediately 10 places I would use this, but they're not obvious that they exist
00:34:06.220 --> 00:34:07.900
or that you could use them until you see them, right?
00:34:07.900 --> 00:34:12.940
Yeah, that's right. And it's, what's the quote there? Like the dose makes the poison or what?
00:34:12.940 --> 00:34:14.600
I only know the German version.
00:34:14.600 --> 00:34:15.760
Yeah.
00:34:15.760 --> 00:34:17.380
Die Dose macht das Gift.
00:34:17.380 --> 00:34:18.360
Yeah.
00:34:18.360 --> 00:34:19.940
So the dose makes the poison.
00:34:19.940 --> 00:34:24.760
Yeah. Basically you don't want to, you want to apply it. It's like salt, you know, you don't
00:34:24.760 --> 00:34:27.360
want to overdo it with the salt because then the food's going to taste it.
00:34:27.360 --> 00:34:31.280
Yeah. Yeah. A pinch will do you. Absolutely. So yeah, that sounds about right.
00:34:31.380 --> 00:34:37.940
Yeah. And so, so this article goes into some use cases and also into the kind of the language
00:34:37.940 --> 00:34:44.360
history or why are these types of functions called lambda functions and how does this relate to this
00:34:44.360 --> 00:34:50.200
thing called lambda calculus that was invented in the 1930s. And we go back into some of the computer
00:34:50.200 --> 00:34:51.080
science stuff.
00:34:51.080 --> 00:34:52.480
Yeah, that's cool.
00:34:52.480 --> 00:34:53.800
So you can also learn about that.
00:34:53.900 --> 00:34:57.880
You know, another thing that I think is interesting that gets very little attention,
00:34:57.880 --> 00:35:03.700
I suspect this is happening to a non-trivial number of people and they don't even know is closure.
00:35:03.700 --> 00:35:08.720
Right? So closure is the idea that like I have a variable that's either available in the local
00:35:08.720 --> 00:35:14.260
method or it's a global variable. Most likely it's like a local variable on that method.
00:35:14.260 --> 00:35:21.540
We're using the lambda and you say it in the function body, the lambda body, but not as an argument.
00:35:22.320 --> 00:35:23.500
Right. It's somehow magically.
00:35:23.500 --> 00:35:25.280
Kind of capturing that.
00:35:25.280 --> 00:35:25.780
Yes.
00:35:25.780 --> 00:35:30.480
I find this so hard to explain just in audio only because when you see it with an example,
00:35:30.480 --> 00:35:35.440
like in the article, it's to me at least a lot easier to wrap my head around it.
00:35:35.440 --> 00:35:37.260
But yeah, let's give it a shot.
00:35:37.260 --> 00:35:37.700
Like can we.
00:35:37.700 --> 00:35:41.720
Yeah. Well, some really interesting stuff happens with closure, right?
00:35:41.720 --> 00:35:46.400
It's not just that the variable is like passed, but it's remembered.
00:35:46.400 --> 00:35:48.880
It's remembered across function calls.
00:35:49.040 --> 00:35:53.680
So even if you change it and then you call the lambda again, it will work with not the
00:35:53.680 --> 00:35:56.440
original value like a compi, but it'll work with a changed value.
00:35:56.440 --> 00:36:02.720
Which can really bite you also if you're referring to a mutable object and you think you've kind
00:36:02.720 --> 00:36:08.000
of captured the full state of this object and then it gets changed under you.
00:36:08.000 --> 00:36:13.920
which I think this is also kind of maybe the danger of using lambda is that if you don't
00:36:13.920 --> 00:36:21.440
understand how closures work or when that effect kicks in, that you might be writing code that
00:36:21.440 --> 00:36:24.620
actually breaks under unexpected circumstances.
00:36:24.620 --> 00:36:25.080
Yeah.
00:36:25.080 --> 00:36:29.040
And it can be incredibly hard to understand why if you have no idea that this is happening.
00:36:29.360 --> 00:36:33.000
On the flip side, you can use it for great power as well.
00:36:33.000 --> 00:36:35.360
Like let's just go to like something super simple.
00:36:35.360 --> 00:36:36.720
I want to sort a list.
00:36:36.720 --> 00:36:43.840
I want to say key equals lambda of item, colon, do something with the item, right?
00:36:43.840 --> 00:36:50.840
But maybe there's other variables or other data that's in the function that you want to use to
00:36:50.840 --> 00:36:51.920
decide how you sort.
00:36:51.920 --> 00:36:54.400
Like if it's below this cutoff, I want it first.
00:36:54.400 --> 00:36:59.060
But if it's after this cutoff or like, you know, it's somehow you've got to compute with some other
00:36:59.060 --> 00:37:01.380
data that's not purely just the item.
00:37:01.380 --> 00:37:06.600
Like if you wanted to sort, you had an address book with, I don't know, name and year of birth
00:37:06.600 --> 00:37:10.180
and you wanted to sort it by some calculated value.
00:37:10.180 --> 00:37:10.600
Yeah.
00:37:10.600 --> 00:37:11.760
So like both of them.
00:37:11.760 --> 00:37:12.400
Right, right.
00:37:12.400 --> 00:37:15.060
So if they don't have a date of birth, you could have like, here's the default date of
00:37:15.060 --> 00:37:15.860
birth we're going to use.
00:37:15.860 --> 00:37:16.300
Right, yeah.
00:37:16.300 --> 00:37:16.640
Right, right.
00:37:16.640 --> 00:37:17.200
Substitute something.
00:37:17.200 --> 00:37:19.100
Yeah, they're all going to be born in 1970 or something.
00:37:19.100 --> 00:37:19.480
Who knows?
00:37:19.480 --> 00:37:24.260
So you could like have that as a local variable, but then include that in your sort lambda.
00:37:24.260 --> 00:37:30.660
But the function that's getting called, it only takes the item and the list doesn't know
00:37:30.660 --> 00:37:32.220
about your need of this other variable.
00:37:32.220 --> 00:37:36.180
It's not going to pass it in, but you can just use closure to just capture it and just like
00:37:36.180 --> 00:37:40.140
bring in more arguments into your lambda than would otherwise be available.
00:37:40.140 --> 00:37:42.080
And that's a super powerful thing you can do.
00:37:42.340 --> 00:37:42.400
Yeah.
00:37:42.400 --> 00:37:42.820
Yeah.
00:37:42.820 --> 00:37:47.940
I think that probably the main use case, what I personally use them for, there's also
00:37:47.940 --> 00:37:53.720
a section in the article that talks about whether lambdas are, we can consider them pythonic
00:37:53.720 --> 00:37:54.300
or not.
00:37:54.300 --> 00:37:59.300
Because in PEP 8, which we just talked about, there's actually a recommendation there that
00:37:59.300 --> 00:38:02.160
says you should always use a def statement.
00:38:02.160 --> 00:38:07.000
So define a proper function instead of an assignment statement that binds a lambda expression directly
00:38:07.000 --> 00:38:07.800
to an identifier.
00:38:07.800 --> 00:38:11.660
And so this is like a strong discouragement to using lambdas.
00:38:11.660 --> 00:38:15.040
I think mainly when you actually, you want a named function.
00:38:15.580 --> 00:38:18.940
I think anytime you actually want a named function, you should probably not use a lambda.
00:38:18.940 --> 00:38:22.620
But if it's like a one-off thing, that's where I would use it.
00:38:22.620 --> 00:38:22.860
Yeah.
00:38:22.860 --> 00:38:26.580
You even talk about in your article a little bit, like anonymous functions, meaning they
00:38:26.580 --> 00:38:27.700
have no name.
00:38:28.180 --> 00:38:29.220
You're passing them somewhere.
00:38:29.220 --> 00:38:34.760
You're modifying the behavior like of the sort or whatever, but you're not naming the
00:38:34.760 --> 00:38:35.500
thing doing that.
00:38:35.500 --> 00:38:35.720
Yeah.
00:38:35.720 --> 00:38:36.340
That's right.
00:38:36.340 --> 00:38:40.120
And with great power comes great responsibility.
00:38:40.120 --> 00:38:40.780
That's right.
00:38:41.000 --> 00:38:47.480
I think one of the key essence of the lambda, like decide, should I make a separate function
00:38:47.480 --> 00:38:49.580
or should I make a lambda function?
00:38:49.580 --> 00:38:54.720
I think one of the key differences here, or the key decision, at least for me, is, is it
00:38:54.720 --> 00:39:01.180
going to be clearer to just plunk the implementation right here than to give it a good name and put
00:39:01.180 --> 00:39:01.700
it somewhere else?
00:39:01.700 --> 00:39:05.720
So if it made a lot of sense to give it a good name and put it over there, because it's kind
00:39:05.720 --> 00:39:10.440
of complicated, but the name tells you what it does and then use that as the sort, great,
00:39:10.440 --> 00:39:10.860
do that.
00:39:10.940 --> 00:39:15.080
But if it's like, I'm going to sort just by like sort of list of customers, it's just
00:39:15.080 --> 00:39:17.980
lambda of C colon goes to C dot name.
00:39:17.980 --> 00:39:18.780
Okay.
00:39:18.780 --> 00:39:22.880
Like it would be more confusing to move that away because then you have to be sure like
00:39:22.880 --> 00:39:23.660
sort by name.
00:39:23.660 --> 00:39:24.300
You're like, oh, wait a minute.
00:39:24.300 --> 00:39:25.560
Descending or ascending?
00:39:25.560 --> 00:39:29.940
Well, it used to, they renamed it to say sort by name ascending, but then they actually changed
00:39:29.940 --> 00:39:34.020
implementation to descending, but they forgot to rename it because they're afraid to break
00:39:34.020 --> 00:39:34.500
the code.
00:39:34.500 --> 00:39:38.080
And just like, there's all sorts of weird stuff if you move it away.
00:39:38.080 --> 00:39:43.080
So if it's clearer to have it like in line than lambda, otherwise not lambda.
00:39:43.080 --> 00:39:44.960
That's my test.
00:39:45.120 --> 00:39:46.040
That's a good rule of thumb.
00:39:46.040 --> 00:39:51.840
I feel like I mainly use lambdas for exactly that, that use case and otherwise try to stay
00:39:51.840 --> 00:39:52.280
away from them.
00:39:52.280 --> 00:39:54.280
If you have to line break a lambda, that's a problem.
00:39:54.280 --> 00:39:54.640
Yeah.
00:39:54.640 --> 00:39:54.900
Yeah.
00:39:54.900 --> 00:39:55.480
That's, yeah.
00:39:55.480 --> 00:39:57.220
That's maybe also a good heuristic, right?
00:39:57.220 --> 00:39:57.820
Where, yeah.
00:39:57.820 --> 00:39:58.320
Yeah.
00:39:58.320 --> 00:40:01.600
You could only have, you know, basically you can just put an expression into it.
00:40:01.600 --> 00:40:03.560
So that's the other thing that we haven't even talked about.
00:40:03.560 --> 00:40:06.840
So they're also limited in what you can actually put into a lambda function.
00:40:06.840 --> 00:40:07.020
Right.
00:40:07.020 --> 00:40:12.920
So you can pretty much just have a single expression that would also be the result of which will
00:40:12.920 --> 00:40:16.320
also be returned as the return value of that, of that function.
00:40:16.940 --> 00:40:23.780
And that also limits you, but of course you could use all kinds of ugly work to do something
00:40:23.780 --> 00:40:25.420
that you're not really supposed to do with them.
00:40:26.120 --> 00:40:26.520
Exactly.
00:40:26.520 --> 00:40:27.000
Exactly.
00:40:27.000 --> 00:40:31.700
But you can't have multi-line lambdas in Python, whereas you can in other languages.
00:40:31.700 --> 00:40:33.840
Like for example, C# has lambdas.
00:40:33.840 --> 00:40:37.800
They're basically the same idea, closure and all that, but you can put curly braces and make
00:40:37.800 --> 00:40:40.420
it 20 lines long if you think that's a good idea.
00:40:40.420 --> 00:40:41.780
That's like a great idea.
00:40:41.780 --> 00:40:43.620
JavaScript's kind of like that, right?
00:40:43.620 --> 00:40:48.480
You can like function curly or parenthesis argument and then just curly braces, right?
00:40:48.480 --> 00:40:56.000
So to tell you a secret, I feel like what forced me to understand closures was doing more JavaScript
00:40:56.000 --> 00:40:57.500
development because you cannot avoid them.
00:40:57.500 --> 00:40:59.400
Yeah, closure's all over the place in JavaScript, right?
00:40:59.400 --> 00:40:59.940
Yeah.
00:40:59.940 --> 00:41:00.260
Yeah.
00:41:00.260 --> 00:41:01.400
Yeah, it is for sure.
00:41:01.400 --> 00:41:02.980
And they have like similar ideas.
00:41:02.980 --> 00:41:06.580
They don't call it lambda, but like they have anonymous functions basically.
00:41:06.580 --> 00:41:07.020
Yeah, that's right.
00:41:07.020 --> 00:41:07.280
Yeah.
00:41:07.280 --> 00:41:08.280
All right.
00:41:08.280 --> 00:41:09.480
Are we already at number nine?
00:41:09.480 --> 00:41:10.120
Number nine.
00:41:10.120 --> 00:41:10.700
Number nine.
00:41:10.700 --> 00:41:11.260
There we go.
00:41:11.260 --> 00:41:12.380
Yeah.
00:41:12.380 --> 00:41:15.020
So number nine is about Python coding interviews.
00:41:15.020 --> 00:41:19.840
So the article is called How to Stand Out in a Python Coding Interview by James Timmons.
00:41:19.840 --> 00:41:27.380
And I felt that this is an important topic and it's hopefully also something useful for you,
00:41:27.380 --> 00:41:28.080
dear listener.
00:41:28.080 --> 00:41:32.220
Maybe you have a Python coding interview coming up or you're worried about, you know, when
00:41:32.220 --> 00:41:35.180
the day comes where somebody is going to grill you on your Python skills.
00:41:35.180 --> 00:41:41.640
And we put this article together to cover some common situations there, basically some tips
00:41:41.640 --> 00:41:47.900
that you can use to showcase your deep understanding of the Python programming language.
00:41:47.900 --> 00:41:51.220
Yeah, you've broken into a couple of sections, right?
00:41:51.220 --> 00:41:56.600
You've got like know your built-in functions, know the right data structure, take advantage
00:41:56.600 --> 00:41:57.940
of the standard library, right?
00:41:57.940 --> 00:42:01.360
If somebody says, I want you to use the quick sort, you're like, you know what?
00:42:01.360 --> 00:42:02.320
I created a list.
00:42:02.320 --> 00:42:02.940
Tim sort.
00:42:02.940 --> 00:42:04.380
Yeah, yeah, exactly.
00:42:04.380 --> 00:42:05.420
Or something like that, right?
00:42:05.420 --> 00:42:08.240
Or I think the data structures is super important.
00:42:08.340 --> 00:42:09.140
That's a great giveaway.
00:42:09.140 --> 00:42:14.320
Like I want you to get a bunch of, I don't know, say users and I want you in memory and
00:42:14.320 --> 00:42:18.040
I want you to look them up by ID and I want you to do that quickly, right?
00:42:18.040 --> 00:42:18.640
Like dictionary.
00:42:18.640 --> 00:42:19.460
Yeah, dictionary.
00:42:19.460 --> 00:42:20.940
Does look up quickly happen?
00:42:20.940 --> 00:42:21.700
Is that the question?
00:42:21.700 --> 00:42:22.580
Dictionary.
00:42:22.580 --> 00:42:25.700
Just yell dictionary.
00:42:25.700 --> 00:42:26.400
Dictionary.
00:42:26.400 --> 00:42:27.620
Exactly.
00:42:27.620 --> 00:42:29.940
Or unique or distinct.
00:42:29.940 --> 00:42:30.860
Okay, set, right?
00:42:30.860 --> 00:42:31.080
Yeah.
00:42:31.080 --> 00:42:31.840
Did they say distinct?
00:42:31.840 --> 00:42:32.680
They mean set, right?
00:42:33.140 --> 00:42:38.540
Like just right away, there's, you could have like a complicated 10 line for loop where
00:42:38.540 --> 00:42:39.840
you test, have you seen it before?
00:42:39.840 --> 00:42:41.100
Or set, right?
00:42:41.100 --> 00:42:44.280
Like that's both knowing the built-ins and knowing the right data structures, I think.
00:42:44.280 --> 00:42:44.500
Yeah.
00:42:44.500 --> 00:42:48.120
And it is so much good stuff in the Python standard library or in the core language, you
00:42:48.120 --> 00:42:52.260
know, another great one I think that's worth knowing about is in the collections module,
00:42:52.260 --> 00:42:53.740
the counter class.
00:42:53.740 --> 00:42:54.780
Oh yeah.
00:42:54.780 --> 00:42:59.700
It's if you ever need to count different items or, you know, how often does this string
00:42:59.700 --> 00:43:00.820
or this word occur?
00:43:00.820 --> 00:43:01.380
Right.
00:43:01.380 --> 00:43:02.860
I got a list of text.
00:43:02.860 --> 00:43:04.500
Like a whole bunch of domain names.
00:43:04.500 --> 00:43:07.020
I need to know like how many, each one of them appears.
00:43:07.020 --> 00:43:07.380
Right.
00:43:07.380 --> 00:43:09.920
That sounds like a challenge or it sounds like two lines.
00:43:09.920 --> 00:43:12.900
If you know counter, right?
00:43:12.900 --> 00:43:13.400
Yeah.
00:43:13.400 --> 00:43:16.880
You create a, you import collections, you create a counter, they're most common.
00:43:16.880 --> 00:43:17.500
Right.
00:43:17.500 --> 00:43:22.420
But like these things are incredibly simple when you know them, but if you don't know they
00:43:22.420 --> 00:43:24.180
exist, it's really challenging.
00:43:24.180 --> 00:43:28.920
And I think that's actually a problem from, not a problem, but a, a learning challenge
00:43:28.920 --> 00:43:31.400
kind of going back to your other article.
00:43:31.400 --> 00:43:35.680
I don't remember which number it was, but the one, I think maybe number two about all
00:43:35.680 --> 00:43:37.020
the projects, right?
00:43:37.020 --> 00:43:41.140
Like some of those projects would be really easy if you knew the right libraries.
00:43:41.140 --> 00:43:45.880
But if you thought I have to write this from pure Python from scratch and I've got to implement
00:43:45.880 --> 00:43:46.500
this stuff, right?
00:43:46.500 --> 00:43:48.960
Like, oh, that MP3 player is super hard.
00:43:48.960 --> 00:43:50.920
Like, let me get down to the bytes and look at it.
00:43:50.920 --> 00:43:56.200
Like, no, you pip install like the MP3 library or whatever, like it is that works with that,
00:43:56.200 --> 00:43:56.420
right?
00:43:56.420 --> 00:43:58.880
It's, there's a whole lot of options.
00:43:58.880 --> 00:44:03.120
And I think learning Python is challenging because you learn the language and you think
00:44:03.120 --> 00:44:05.400
you've done it, but you've only like hit the 10%.
00:44:05.400 --> 00:44:07.000
Now you've got to learn the standard library.
00:44:07.000 --> 00:44:11.160
Then you've got to learn everything on awesome Python or PyPI or, right?
00:44:11.160 --> 00:44:12.140
So there's these levels.
00:44:12.140 --> 00:44:17.760
And, you know, but I do think for tests, for interviewing, knowing the foundational stuff
00:44:17.760 --> 00:44:18.520
is most important.
00:44:18.520 --> 00:44:19.000
I agree.
00:44:19.000 --> 00:44:19.240
Yeah.
00:44:19.240 --> 00:44:23.740
And we were thinking, you know, we're going to pick stuff that is actually very likely to
00:44:23.740 --> 00:44:28.780
come up in an interview because in an interview, I think you're not going to get super specific.
00:44:28.780 --> 00:44:34.420
You know, you're not going to talk about the LMHDB or whatever the lightning memory database
00:44:34.420 --> 00:44:35.340
that we talked about earlier.
00:44:35.600 --> 00:44:40.280
That would be, nobody's going to expect, I mean, depending on the kind of role, but if
00:44:40.280 --> 00:44:43.260
it's, if it's data science, they might expect you to know NumPy.
00:44:43.260 --> 00:44:43.660
Right.
00:44:43.660 --> 00:44:47.460
If you've claimed, you know, Python, you better know NumPy at least cursory, right?
00:44:47.460 --> 00:44:47.640
Yeah.
00:44:47.640 --> 00:44:52.000
And if you claim that you, you especially better know about things like the collections module,
00:44:52.000 --> 00:44:53.520
you know, these like core things.
00:44:53.520 --> 00:44:53.820
Yeah.
00:44:53.820 --> 00:44:54.020
Yeah.
00:44:54.020 --> 00:44:54.600
For sure.
00:44:54.600 --> 00:44:55.000
Yeah.
00:44:55.000 --> 00:44:56.980
What about when you get stumped?
00:44:56.980 --> 00:45:00.180
What is your thoughts on like, you know, how do I do this thing?
00:45:00.180 --> 00:45:04.060
Like, you know, inside your thing, screaming, like I have no idea.
00:45:04.060 --> 00:45:04.120
Yeah.
00:45:04.120 --> 00:45:07.340
I start sweating profusely and shivering.
00:45:07.340 --> 00:45:09.760
Go into the fetal position.
00:45:09.760 --> 00:45:11.520
That's why I'm running my own company now.
00:45:11.520 --> 00:45:13.260
Yeah.
00:45:13.260 --> 00:45:14.080
No, that's a tough one.
00:45:14.080 --> 00:45:20.320
I think the advice that I would give is start asking questions because it's oftentimes not
00:45:20.320 --> 00:45:24.400
a good sign if you ask someone a question in an interview setting and they immediately launch
00:45:24.400 --> 00:45:28.360
into writing code or they feel like they're expected to know the answer off the bat.
00:45:28.360 --> 00:45:33.300
A lot of times what the interviewer will want to see is how are you approaching a problem?
00:45:33.420 --> 00:45:34.740
Are you able to get help?
00:45:34.740 --> 00:45:36.380
Are you able to ask intelligent questions?
00:45:36.380 --> 00:45:40.140
And even if you don't know the specifics, I mean, nobody really expects that, right?
00:45:40.140 --> 00:45:43.880
A lot of times if you can use Google, if you can use Stack Overflow, if you can use, you
00:45:43.880 --> 00:45:48.520
know, Talk Python and RealPython and all these sites that are available to you, you would have
00:45:48.520 --> 00:45:50.100
that in your normal working environment.
00:45:50.100 --> 00:45:55.380
You know, like I use Google and Stack Overflow like probably like hundreds of times in a productive
00:45:55.380 --> 00:45:55.720
day.
00:45:55.720 --> 00:46:00.140
I use it shamelessly without guilt or judgment, right?
00:46:00.140 --> 00:46:03.940
I mean, because there's a bunch of stuff that you need to know and then there's a bunch
00:46:03.940 --> 00:46:08.940
of stuff that just doesn't deserve to take up space in your memory, right?
00:46:08.940 --> 00:46:11.680
And you should just be able to go, I'm just going to Google it.
00:46:11.680 --> 00:46:14.740
I don't know what the right way to do this library with that thing is.
00:46:14.740 --> 00:46:15.920
I'm going to Google it.
00:46:16.160 --> 00:46:19.600
But just like actually knowing that it exists and I just don't remember quite how to use
00:46:19.600 --> 00:46:21.000
it, I think is like the big step.
00:46:21.000 --> 00:46:26.100
Like I know I know there's a counter thing and I know I can get it to group by the count.
00:46:26.100 --> 00:46:30.220
I just don't remember how to the steps to make that happen, right?
00:46:30.220 --> 00:46:31.820
Like I think that's okay.
00:46:31.820 --> 00:46:33.260
Yeah, I think that's totally okay.
00:46:33.260 --> 00:46:35.280
So just duck, duck, go it.
00:46:35.280 --> 00:46:36.120
Just bing it.
00:46:36.120 --> 00:46:37.520
Google it.
00:46:37.520 --> 00:46:39.760
Just duck, duck, go it.
00:46:39.760 --> 00:46:40.540
AltaVista it.
00:46:40.540 --> 00:46:41.600
I don't know what else is there.
00:46:41.600 --> 00:46:42.220
Yahoo it.
00:46:42.220 --> 00:46:42.920
Yeah, yeah.
00:46:42.920 --> 00:46:43.960
AltaVista.
00:46:43.960 --> 00:46:44.460
That's a good one.
00:46:44.460 --> 00:46:44.980
I remember that.
00:46:44.980 --> 00:46:45.700
That was good.
00:46:45.980 --> 00:46:50.800
One other thing I would sort of put out there is like a huge turnoff to me if I was
00:46:50.800 --> 00:46:52.540
interviewing, I did that for a while with people.
00:46:52.540 --> 00:46:55.980
If I feel like they are lying to me, they're done.
00:46:55.980 --> 00:46:57.220
I don't care if they seem good.
00:46:57.220 --> 00:47:00.180
If I say like, oh, how would you do that with SQLAlchemy?
00:47:00.180 --> 00:47:02.120
Oh, like I've used so much SQLAlchemy.
00:47:02.120 --> 00:47:06.380
And then you can tell like they've never, ever, ever seen it, right?
00:47:06.380 --> 00:47:09.480
Like they don't even, they can't even describe like, well, what I would do is create a class
00:47:09.480 --> 00:47:12.460
that derives from like another class and it maps to the database.
00:47:12.460 --> 00:47:14.160
Like that's a foreign idea.
00:47:14.800 --> 00:47:17.420
But they're claiming like they've used it in production.
00:47:17.420 --> 00:47:18.580
Like done.
00:47:18.580 --> 00:47:19.580
Not a good strategy.
00:47:19.580 --> 00:47:20.900
Not, I would, I don't know.
00:47:20.900 --> 00:47:21.260
How do you feel?
00:47:21.260 --> 00:47:22.900
Like, would you hire that person?
00:47:22.900 --> 00:47:24.760
Because everything else comes to the question, right?
00:47:24.860 --> 00:47:25.200
I agree.
00:47:25.200 --> 00:47:26.460
It's, it's, yeah.
00:47:26.460 --> 00:47:26.940
It's at that.
00:47:26.940 --> 00:47:29.940
You want to find, find out, would you ask the interviewer?
00:47:29.940 --> 00:47:33.480
I feel like you also want to find out, would you want to have this person on your team?
00:47:33.480 --> 00:47:34.460
Would you want to work with them?
00:47:34.460 --> 00:47:34.700
Right.
00:47:34.700 --> 00:47:36.360
Would I trust them to be?
00:47:36.360 --> 00:47:36.520
Yeah.
00:47:36.520 --> 00:47:40.420
They start making up stuff like, hey, you know, did you review that pull request or request?
00:47:40.420 --> 00:47:42.260
Or did you merge that hot fix?
00:47:42.260 --> 00:47:43.640
Or did you, I don't know, do that?
00:47:43.760 --> 00:47:47.420
And then you feel like you can't really rely on that person and it's not a good start.
00:47:47.420 --> 00:47:50.160
Or we're going to build an e-commerce backend.
00:47:50.160 --> 00:47:53.540
Who's done payment stuff before and feels like they can do it, right?
00:47:53.540 --> 00:47:54.960
And maybe not.
00:47:54.960 --> 00:47:55.260
I don't know.
00:47:55.260 --> 00:47:56.920
Definitely use floats for currency.
00:47:56.920 --> 00:47:57.520
Yeah.
00:47:58.940 --> 00:48:02.300
I don't know if we have that one in the list, but that's, that's also a really common question.
00:48:02.300 --> 00:48:06.280
I feel like where people are like, oh, what data type should you use to represent currency
00:48:06.280 --> 00:48:06.840
in your program?
00:48:06.840 --> 00:48:07.240
Right.
00:48:07.240 --> 00:48:07.740
Right.
00:48:07.740 --> 00:48:08.880
Integers probably.
00:48:08.880 --> 00:48:09.240
Yeah.
00:48:09.240 --> 00:48:09.480
Yeah.
00:48:09.480 --> 00:48:11.960
And then break it down to sense and then use integers.
00:48:11.960 --> 00:48:12.260
Yeah.
00:48:12.260 --> 00:48:13.000
Just round it.
00:48:13.000 --> 00:48:13.560
Just round it.
00:48:13.560 --> 00:48:13.660
Just round it.
00:48:13.660 --> 00:48:15.640
About a dollar.
00:48:15.640 --> 00:48:16.060
Yeah.
00:48:16.060 --> 00:48:19.720
It's all good.
00:48:19.720 --> 00:48:20.320
It's about a dollar.
00:48:20.320 --> 00:48:21.240
All right.
00:48:21.240 --> 00:48:24.660
Well, we're coming up on the grand finale here.
00:48:24.660 --> 00:48:26.980
And this is another one that I could, I'm very passionate about.
00:48:26.980 --> 00:48:28.280
I could riff on for a long time.
00:48:28.280 --> 00:48:33.800
So you'll have to stop me at some point, but it has to do with the object oriented programming
00:48:33.800 --> 00:48:35.540
component of Python.
00:48:35.540 --> 00:48:36.420
Yeah.
00:48:36.420 --> 00:48:42.960
So the article is called inheritance and composition, a Python OOP guide by Isaac Rodriguez.
00:48:42.960 --> 00:48:50.180
And I think inheritance and composition, that is the, one of the core pieces of object oriented
00:48:50.180 --> 00:48:50.620
programming.
00:48:50.620 --> 00:48:56.900
And in my experience, it's also the piece that if you're completely new to OOP and you're trying
00:48:56.900 --> 00:48:58.520
to understand, okay, well, how is this helpful?
00:48:58.520 --> 00:48:59.640
Like how does this work?
00:48:59.640 --> 00:49:01.520
It can be a sticking point for some people.
00:49:01.520 --> 00:49:01.660
Yeah.
00:49:01.660 --> 00:49:05.880
So we wanted to do a dedicated article that is, yeah, basically a deep dive on inheritance.
00:49:05.880 --> 00:49:10.420
It sounds a little bit like modeling with objects and just like some practices around
00:49:10.420 --> 00:49:10.680
that.
00:49:10.680 --> 00:49:11.020
Right.
00:49:11.020 --> 00:49:11.240
Yeah.
00:49:11.240 --> 00:49:17.380
And how do you go about like breaking down a hierarchy or like, I guess a domain into a
00:49:17.380 --> 00:49:18.240
hierarchy of objects?
00:49:18.240 --> 00:49:18.480
Yes.
00:49:18.480 --> 00:49:19.600
Yeah, exactly.
00:49:19.660 --> 00:49:20.180
That was getting at.
00:49:20.180 --> 00:49:23.640
And so maybe we should define inheritance and composition.
00:49:23.640 --> 00:49:25.140
I think inheritance is pretty clear.
00:49:25.140 --> 00:49:27.540
Composition might be a little less well known.
00:49:27.540 --> 00:49:31.280
So inheritance is, I want to model like a bunch of cars.
00:49:31.280 --> 00:49:37.220
So I have a basic car or just a car, but then I have a sports car that does sporty things,
00:49:37.220 --> 00:49:37.400
right?
00:49:37.400 --> 00:49:42.720
Maybe it has like paddle shifters or it has like a manual transmission mode that has additional
00:49:42.720 --> 00:49:43.400
functionality.
00:49:43.400 --> 00:49:46.400
So I might say, all right, well, the idea is what we're going to do is we're going to
00:49:46.400 --> 00:49:48.420
create a car and a sports car.
00:49:48.420 --> 00:49:51.860
And then maybe I want to have a track car that can also take slicks.
00:49:51.860 --> 00:49:53.340
Like, so it derives from sports car.
00:49:53.340 --> 00:50:01.140
And the deeper that those get, the more full of the abstractions can break down pretty hard,
00:50:01.140 --> 00:50:01.380
right?
00:50:01.380 --> 00:50:07.720
Like, you know, if you model creatures, I've got a living animal and then I've got a bird
00:50:07.720 --> 00:50:11.580
and then I've got, what do you do with a robot bird, right?
00:50:11.580 --> 00:50:12.660
Does it drive from bird?
00:50:12.660 --> 00:50:13.060
That's a hard one.
00:50:13.360 --> 00:50:13.520
Right.
00:50:13.520 --> 00:50:17.980
Like it, it has bird like things, but the animal eats, robot doesn't eat.
00:50:17.980 --> 00:50:18.180
Right.
00:50:18.180 --> 00:50:20.680
So like if you go too deep, it makes, it's a problem.
00:50:20.680 --> 00:50:20.920
Right.
00:50:20.920 --> 00:50:22.300
So that's inheritance, obviously.
00:50:22.300 --> 00:50:23.340
Composition.
00:50:23.340 --> 00:50:24.080
Tell us about it.
00:50:24.080 --> 00:50:24.620
So composition.
00:50:24.620 --> 00:50:27.680
So if inheritance defines is a relationship.
00:50:27.680 --> 00:50:33.480
So like a sports car is a car and the car is a vehicle and a vehicle is a thing or whatever
00:50:33.480 --> 00:50:33.940
machine.
00:50:33.940 --> 00:50:37.320
Composition defines a, has a relationship.
00:50:37.320 --> 00:50:43.320
So you can say, okay, a car has an engine or a car has a steering wheel.
00:50:43.320 --> 00:50:43.760
Right.
00:50:43.760 --> 00:50:44.820
And it has a transmission.
00:50:44.820 --> 00:50:49.320
Instead of making a sports car, maybe you just make a car with a sporty transmission.
00:50:49.320 --> 00:50:50.140
Right.
00:50:50.140 --> 00:50:55.460
And so the whole thing doesn't have to like, because I don't know, what if you have some
00:50:55.460 --> 00:50:58.060
kind of truck, but it also has like a manual shifting thing, right?
00:50:58.060 --> 00:50:59.300
It could, right.
00:50:59.300 --> 00:51:01.480
You wouldn't have a truck derived from a sports car.
00:51:01.480 --> 00:51:02.220
That would be weird.
00:51:02.220 --> 00:51:02.480
Right.
00:51:02.480 --> 00:51:07.840
But you could easily like interchange the parts and it, it helps really alleviate some
00:51:07.840 --> 00:51:10.060
of those like deep object hierarchies.
00:51:10.060 --> 00:51:10.560
I think.
00:51:10.560 --> 00:51:11.020
Yeah.
00:51:11.020 --> 00:51:11.060
Yeah.
00:51:11.060 --> 00:51:15.180
It's, it's basically another tool in your toolbox there for defining these relationships.
00:51:15.180 --> 00:51:19.960
Because if, if you define everything in terms of a inheritance relationship, then you end
00:51:19.960 --> 00:51:24.380
up with these unmaintainable, like the, you end up on the dark side of OOP.
00:51:24.380 --> 00:51:25.320
That's right.
00:51:25.320 --> 00:51:32.060
And like small changes to like a deep down base class can make absurd things in the end, like
00:51:32.060 --> 00:51:34.520
a robot that has to eat or something like that.
00:51:34.520 --> 00:51:36.560
Cause maybe the animal didn't eat at first and that made sense.
00:51:36.560 --> 00:51:38.800
But now later you realize all the animals have to eat.
00:51:38.800 --> 00:51:41.680
And then like, well, what do you do about the robot thing that we put there?
00:51:41.680 --> 00:51:46.140
Like that's where you use multiple inheritances, which is like a whole dutter of can of worms.
00:51:46.140 --> 00:51:48.980
That's a deep, that's a big can of worms as well for sure.
00:51:48.980 --> 00:51:50.360
But I, I'm a big fan of composition.
00:51:50.360 --> 00:51:54.800
I think, I can't remember where I heard, I'm pretty sure the original gang of four design
00:51:54.800 --> 00:51:57.940
patterns books said prefer composition over inheritance.
00:51:57.940 --> 00:51:59.040
Yeah.
00:51:59.040 --> 00:52:00.840
Like you want shallow hierarchies.
00:52:00.840 --> 00:52:01.100
Yeah.
00:52:01.140 --> 00:52:05.000
Like you're going to like it's objects and inherits aren't inherently bad, but they're
00:52:05.000 --> 00:52:06.040
easy to abuse.
00:52:06.040 --> 00:52:11.240
And so composition is a really way, good way to keep those shallow and interchangeable and
00:52:11.240 --> 00:52:11.640
small.
00:52:11.640 --> 00:52:13.760
So yeah, quite, quite cool.
00:52:13.760 --> 00:52:14.780
I like this one a lot.
00:52:14.780 --> 00:52:15.100
Wow.
00:52:15.100 --> 00:52:16.880
Did we really make it to the, all the way?
00:52:16.880 --> 00:52:20.180
Oh, actually speaking of the gang of four book, I think that might be a recommendation
00:52:20.180 --> 00:52:23.480
here at the end of the article because we, yeah.
00:52:23.480 --> 00:52:24.340
Also always give.
00:52:24.340 --> 00:52:24.560
Yeah.
00:52:24.560 --> 00:52:26.780
So the article comes with recommended reading, right?
00:52:26.780 --> 00:52:27.080
Yeah.
00:52:27.080 --> 00:52:27.400
Yeah.
00:52:27.400 --> 00:52:29.900
It's got some cool design, design patterns.
00:52:30.340 --> 00:52:34.940
head first design patterns, clean code, solid principles, list cove substitution principle,
00:52:34.940 --> 00:52:36.080
all those kinds of things.
00:52:36.080 --> 00:52:36.240
Yeah.
00:52:36.240 --> 00:52:37.160
A lot of these apply.
00:52:37.160 --> 00:52:44.400
It would be remiss of us, I think, to riff so fondly on like an object oriented story in
00:52:44.400 --> 00:52:50.500
Python without seeing that like a lot of what people do with objects and classes and other
00:52:50.500 --> 00:52:53.360
languages is simply unnecessary in Python.
00:52:53.360 --> 00:52:53.760
Right.
00:52:54.080 --> 00:52:58.920
So there is a little bit of pushback and well, I know you did Java and everything had
00:52:58.920 --> 00:52:59.620
to be a class.
00:52:59.620 --> 00:53:01.660
You don't have to build it this way.
00:53:01.660 --> 00:53:01.900
Right.
00:53:01.900 --> 00:53:07.300
Like for example, if you have a variable that you need to be basically a singleton and then
00:53:07.300 --> 00:53:11.820
you want to group a bunch of functions together, you could have a static class that has those
00:53:11.820 --> 00:53:15.180
in there in like Java or C# or something like that.
00:53:15.420 --> 00:53:21.740
But you could also in Python just have a module that has a variable and it has functions.
00:53:21.740 --> 00:53:26.920
And then if you just import that module, you say that module dot the fields or the
00:53:26.920 --> 00:53:29.960
variables or the functions, that's the same thing as a static class.
00:53:29.960 --> 00:53:30.160
Right.
00:53:30.160 --> 00:53:30.380
Yeah.
00:53:30.380 --> 00:53:30.720
Right.
00:53:30.720 --> 00:53:35.320
You don't have, and you don't, it saves you a bunch of work and it's, it's more Pythonic.
00:53:35.320 --> 00:53:35.660
Yes.
00:53:35.740 --> 00:53:36.100
I guess.
00:53:36.100 --> 00:53:36.380
Right.
00:53:36.380 --> 00:53:38.160
Then making everything a class.
00:53:38.160 --> 00:53:38.460
Yeah.
00:53:38.460 --> 00:53:43.100
So there, I mean, maybe there's a little bit of, do I really need a class for that?
00:53:43.100 --> 00:53:43.780
Right.
00:53:43.780 --> 00:53:47.200
If you're going to create different ones over there, different values at the same time, like,
00:53:47.200 --> 00:53:47.800
well, probably.
00:53:47.800 --> 00:53:48.100
Right.
00:53:48.100 --> 00:53:50.920
But maybe if you're like just trying to group stuff, maybe the modules, right thing.
00:53:50.920 --> 00:53:56.100
But if you do decide and it does make sense to have a class, this inheritance versus composition
00:53:56.100 --> 00:53:57.620
thing is super important to understand.
00:53:57.620 --> 00:53:58.460
Yeah, absolutely.
00:53:58.460 --> 00:54:02.060
And I don't want to give the impression that like, you know, if you, if you're writing in an object
00:54:02.060 --> 00:54:05.500
oriented programming state style, that that's somehow superior or like the end
00:54:05.500 --> 00:54:07.400
all, you know, of, of coding.
00:54:07.400 --> 00:54:09.220
I don't, I don't think that's, that's actually true.
00:54:09.220 --> 00:54:13.560
I think the really powerful thing is understanding these tools, like to have a really
00:54:13.560 --> 00:54:17.620
big toolbox and being able to pick the things that make the most sense.
00:54:17.620 --> 00:54:20.800
Like a lot of times, you know, when, when I'm writing a program in Python or I'm sketching
00:54:20.800 --> 00:54:24.920
something out, I, I'll hardly like write any classes depending on, on the use case.
00:54:24.920 --> 00:54:30.460
Or I found myself, you know, most recently just basically adding like these, like, so I've
00:54:30.460 --> 00:54:35.180
been working on the real Python platform a lot and I've been writing more function-based
00:54:35.260 --> 00:54:41.680
codes or procedural code where maybe my data model is class-based, but then I'll have,
00:54:41.680 --> 00:54:47.060
you know, a module or I don't know, redeeming access codes or coupon codes or something like
00:54:47.060 --> 00:54:47.220
that.
00:54:47.220 --> 00:54:50.680
And it basically defines like a really nice high level interview interface to me.
00:54:50.680 --> 00:54:54.360
These are the five operations you do on coupons or something, right?
00:54:54.360 --> 00:54:54.540
Yeah.
00:54:54.540 --> 00:54:54.800
Yeah.
00:54:54.800 --> 00:54:56.320
And that's all function-based.
00:54:56.320 --> 00:54:56.660
Yeah.
00:54:56.660 --> 00:55:01.480
And then internally they, they use classes to kind of represent the data and, and shuffle
00:55:01.480 --> 00:55:01.840
it around.
00:55:01.840 --> 00:55:03.960
Probably working with Django ORM or something like that.
00:55:04.040 --> 00:55:04.200
Right.
00:55:04.200 --> 00:55:04.520
Yeah.
00:55:04.520 --> 00:55:04.880
Yeah.
00:55:04.880 --> 00:55:04.980
Yeah.
00:55:04.980 --> 00:55:09.300
Instead of cramming that all into a view or actually I prefer, for example, a function-based
00:55:09.300 --> 00:55:12.840
views in Django instead of class-based views because I don't like sort of the getting the
00:55:12.840 --> 00:55:13.740
deeper intendation.
00:55:13.740 --> 00:55:20.140
I would, we could, we could get into all kinds of, disagreements there, but, yeah,
00:55:20.140 --> 00:55:23.620
just, just want to make sure, you know, that, that I get this across that, I don't
00:55:23.620 --> 00:55:30.100
think the OOP coding style is, not the one true way that the one true way that this
00:55:30.100 --> 00:55:31.760
should be one, exactly one way to do things.
00:55:31.760 --> 00:55:32.180
Yeah.
00:55:32.180 --> 00:55:32.460
Yeah.
00:55:32.460 --> 00:55:35.520
But if you're going to do it, like understanding this, this difference between inheritance
00:55:35.520 --> 00:55:37.340
composition, certainly, it certainly makes sense.
00:55:37.340 --> 00:55:39.060
I do a lot of what you're recommending there as well.
00:55:39.060 --> 00:55:39.740
All right.
00:55:39.740 --> 00:55:42.180
Well, that's our top 10 items, Dan.
00:55:42.180 --> 00:55:42.740
Yeah.
00:55:42.740 --> 00:55:45.220
That, that went by super fast.
00:55:45.300 --> 00:55:45.460
Yeah.
00:55:45.460 --> 00:55:49.880
It did go by fast, but I think these all have special value and, you know, people might
00:55:49.880 --> 00:55:51.120
be kicking back.
00:55:51.120 --> 00:55:53.520
A lot of folks have vacation time around this time of year.
00:55:53.520 --> 00:55:57.920
You know, they're also thinking of what's coming in the next year in 2020.
00:55:57.920 --> 00:56:05.180
I mean, first of all, let's just take a moment and say, thank you, Python 2, but goodbye.
00:56:05.180 --> 00:56:05.580
Yeah.
00:56:05.580 --> 00:56:05.980
Bye-bye.
00:56:05.980 --> 00:56:07.540
We'll miss you.
00:56:07.540 --> 00:56:12.060
The death plot is down to single digit days probably at this point.
00:56:12.060 --> 00:56:12.360
Right.
00:56:12.360 --> 00:56:14.340
So that's actually pretty exciting.
00:56:14.540 --> 00:56:14.620
Yeah.
00:56:14.620 --> 00:56:15.660
That's a big change, right?
00:56:15.660 --> 00:56:15.960
Yeah.
00:56:15.960 --> 00:56:16.220
Yeah.
00:56:16.220 --> 00:56:16.540
You're right.
00:56:16.540 --> 00:56:16.880
Yeah.
00:56:16.880 --> 00:56:17.220
Cool.
00:56:17.220 --> 00:56:17.540
All right.
00:56:17.540 --> 00:56:21.360
Well, there's a bunch of articles for people to check out while they're on vacation, got
00:56:21.360 --> 00:56:22.280
some time away from work.
00:56:22.280 --> 00:56:24.940
They don't have to, you know, fill out TPS reports all day.
00:56:24.940 --> 00:56:27.140
Smashed out printer.
00:56:27.140 --> 00:56:27.760
That's right.
00:56:27.760 --> 00:56:28.460
Smashed out printer.
00:56:28.460 --> 00:56:29.540
Awesome.
00:56:29.540 --> 00:56:29.940
All right.
00:56:29.940 --> 00:56:31.340
Well, thanks for being here as always.
00:56:31.340 --> 00:56:31.580
Cool.
00:56:31.580 --> 00:56:31.720
Yeah.
00:56:31.720 --> 00:56:32.480
Thanks for inviting me.
00:56:32.480 --> 00:56:33.000
This is great.
00:56:33.000 --> 00:56:33.380
You're welcome.
00:56:33.380 --> 00:56:35.800
I guess I should ask you the two questions before you go.
00:56:35.800 --> 00:56:40.480
So the two questions are, what editor do you use to write Python code these days?
00:56:40.480 --> 00:56:43.540
So I've started to use Visual Studio Code a lot.
00:56:43.780 --> 00:56:46.260
I use Sublime Text.
00:56:46.260 --> 00:56:46.620
Yeah.
00:56:46.620 --> 00:56:49.380
It's a pretty similar style of editor.
00:56:49.380 --> 00:56:49.840
Very similar.
00:56:49.840 --> 00:56:50.180
Right.
00:56:50.180 --> 00:56:50.520
Yeah.
00:56:50.520 --> 00:56:53.580
What I still love about Sublime is just how fast it is.
00:56:53.580 --> 00:56:58.600
Like there's a noticeable difference in the rendering speed and scrolling around.
00:56:58.600 --> 00:57:05.020
But the Python integration that VS Code has out of the box is really cool.
00:57:05.020 --> 00:57:07.120
It's growing and growing all the things it can do.
00:57:07.120 --> 00:57:12.200
I like it for recording video courses because I can have an integrated shell there.
00:57:12.200 --> 00:57:14.420
I can have a setup that looks really, really nice, I think.
00:57:14.420 --> 00:57:16.780
And so I've been doing that a lot recently.
00:57:16.780 --> 00:57:17.480
And so, yeah.
00:57:17.480 --> 00:57:19.480
Working out of VS Code.
00:57:19.480 --> 00:57:19.760
Yeah.
00:57:19.760 --> 00:57:20.200
Awesome.
00:57:20.740 --> 00:57:22.840
The other question changing for today.
00:57:22.840 --> 00:57:25.160
What's next for RealPython in 2020?
00:57:25.160 --> 00:57:26.420
100 authors?
00:57:26.420 --> 00:57:26.840
Yeah.
00:57:26.840 --> 00:57:27.700
That's a big goal of mine.
00:57:27.700 --> 00:57:31.280
You know, I want to, I would love to have 100 authors published on the site.
00:57:31.280 --> 00:57:33.700
Authors and instructors as a magical number.
00:57:33.700 --> 00:57:37.580
And, you know, maybe we'll crack that 3 million visitors.
00:57:37.720 --> 00:57:39.640
I don't know how many Python developers are out there.
00:57:39.640 --> 00:57:43.340
Well, I suspect after they listen to this episode, it'll probably be 3 million straight up.
00:57:43.340 --> 00:57:44.180
It'll be 10 more.
00:57:44.180 --> 00:57:46.480
For sure.
00:57:46.480 --> 00:57:47.180
It's going to, yeah.
00:57:47.180 --> 00:57:47.740
Awesome.
00:57:47.740 --> 00:57:50.380
Well, best of luck in 2020 and keep up the good work.
00:57:50.380 --> 00:57:51.820
It's a huge resource for everyone.
00:57:51.820 --> 00:57:52.220
Thank you.
00:57:52.220 --> 00:57:53.300
I mean, you know, same to you.
00:57:53.300 --> 00:57:56.280
Like, it's been so cool just becoming friends with you.
00:57:56.280 --> 00:57:59.900
And when we first met, which was, I think, like three years ago.
00:57:59.900 --> 00:58:00.680
Three or four years ago.
00:58:00.680 --> 00:58:01.680
It's quite a while back.
00:58:01.680 --> 00:58:03.880
And just being on this journey here together.
00:58:03.880 --> 00:58:05.120
I really appreciate that.
00:58:05.120 --> 00:58:06.000
Yeah, absolutely.
00:58:06.000 --> 00:58:06.400
Thank you.
00:58:06.400 --> 00:58:06.780
Same to you.
00:58:06.860 --> 00:58:08.080
It's been fun to be on it together.
00:58:08.080 --> 00:58:08.700
Awesome, man.
00:58:08.700 --> 00:58:09.040
All right.
00:58:09.040 --> 00:58:09.780
Well, catch you later.
00:58:09.780 --> 00:58:10.180
Bye.
00:58:10.180 --> 00:58:10.480
Yeah.
00:58:10.480 --> 00:58:10.740
Bye-bye.
00:58:10.740 --> 00:58:14.940
This has been another episode of Talk Python To Me.
00:58:14.940 --> 00:58:17.320
Our guest on this episode was Dan Bader.
00:58:17.320 --> 00:58:20.200
And it's been brought to you by Linode and Brilliant.org.
00:58:20.200 --> 00:58:24.620
Start your next Python project on Linode's state-of-the-art cloud service.
00:58:24.620 --> 00:58:27.780
Just visit talkpython.fm/Linode.
00:58:27.780 --> 00:58:29.140
L-I-N-O-D-E.
00:58:29.140 --> 00:58:32.340
You'll automatically get a $20 credit when you create a new account.
00:58:32.340 --> 00:58:36.000
Brilliant.org encourages you to give the gift
00:58:36.000 --> 00:58:37.380
of critical thought and knowledge.
00:58:37.380 --> 00:58:43.140
Visit talkpython.fm/brilliant and grab a gift subscription to help your loved ones finish
00:58:43.140 --> 00:58:44.740
their day a little smarter this season.
00:58:44.740 --> 00:58:47.100
Want to level up your Python?
00:58:47.100 --> 00:58:51.960
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
00:58:51.960 --> 00:58:57.060
Or if you're looking for something more advanced, check out our new async course that digs into
00:58:57.060 --> 00:59:00.120
all the different types of async programming you can do in Python.
00:59:00.380 --> 00:59:04.080
And of course, if you're interested in more than one of these, be sure to check out our
00:59:04.080 --> 00:59:04.780
Everything Bundle.
00:59:04.780 --> 00:59:06.660
It's like a subscription that never expires.
00:59:06.660 --> 00:59:08.820
Be sure to subscribe to the show.
00:59:08.820 --> 00:59:11.240
Open your favorite podcatcher and search for Python.
00:59:11.240 --> 00:59:12.460
We should be right at the top.
00:59:12.460 --> 00:59:17.280
You can also find the iTunes feed at /itunes, the Google Play feed at /play,
00:59:17.280 --> 00:59:21.440
and the direct RSS feed at /rss on talkpython.fm.
00:59:21.940 --> 00:59:23.520
This is your host, Michael Kennedy.
00:59:23.520 --> 00:59:25.020
Thanks so much for listening.
00:59:25.020 --> 00:59:26.080
I really appreciate it.
00:59:26.080 --> 00:59:27.840
Now get out there and write some Python code.
00:59:27.840 --> 00:59:48.460
I'll see you next time.