Learn Python with Talk Python's 270 hours of courses

#86: Python at StackOverflow Transcript

Recorded on Wednesday, Nov 2, 2016.

00:00 If you run into a problem with some API or Python code, what do you do to solve it?

00:04 Well, personally, I throw a few keywords into Google, sometimes before even checking the full

00:08 docs. It works great. But why does it work so well? Because invariably, an excellent conversation

00:14 and answer from Stack Overflow comes back as the top result, and it's usually just what I needed.

00:19 This week, you'll meet Martin Peters, one of the top Python contributors at Stack Overflow,

00:24 with over 16,500 questions answered and a reputation of over half a million.

00:30 This is Talk Python to Me, episode 86, recorded November 2nd, 2016.

00:49 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the

01:05 ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter,

01:10 where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm,

01:15 and follow the show on Twitter via at talkpython. This episode has been sponsored by Rollbar and

01:21 GoCD. Thank them both for supporting the podcast by checking out what they're offering during their

01:27 segments. Martin, welcome to Talk Python. Hi there. This is exciting. Yeah, it's an honor to have you

01:33 here. You've done some really amazing work in the Python space on Stack Overflow, and we're going to

01:39 spend a lot of time talking about what you've done there, what your experiences were, but also kind of a

01:44 survey. Some really cool questions that you've pulled out for us to talk about that are representative

01:50 of good work and basically the Python community at Stack Overflow. But of course, before we get to

01:57 any of that, let's start with your story. How did you get into Python and programming? I started

02:00 programming quite early on. My father was a computer engineer. He fixed computers the way you fix a bike.

02:07 You find the part that breaks and solder a new one in back in the 70s. So in the 80s, I finally got my own

02:13 computer. I was given a MSX. And I basically haven't looked back since. Python. I started Python in 1999, I think,

02:22 when I was a web developer and I found a new platform called Zope. It lets you think of web pages as components

02:31 and as objects, which was interesting. And that called me into Python at the same time. My first project, I gave a time estimate

02:38 and beat my own time estimate, which blew away my manager because that never happened before. I always go over time.

02:45 That's all engineers do. And I haven't... That was my start with Python. It really was a love at first sight, I think.

02:53 Yeah, that's great. And what kind of project was that? That Zope project?

02:56 It was for a befriended company that was doing software on the web. And when you sell software on the web, you need a web shop.

03:06 So I built a web shop. I see. And because their software was already built in Python, it was very easy to incorporate their license generator into it too.

03:15 Oh, of course. Yeah. So they were selling Python software. You needed to run their license thing. It's just like, yeah, we'll just, you know, import that right here.

03:22 Just plug it in?

03:22 Yeah, yeah. Beautiful. That's great that it was quick and easy. But I think building e-commerce sites today, quite a bit easier than it was back in 1999.

03:31 What do you think? Have you built one recently?

03:33 I tend to stay away from shop. I've mostly done, in my career, I've mostly done content management.

03:40 So I think an intranet website where everybody has to be able to give their input as to what the company is doing or whatever. Share between teams, that kind of stuff.

03:49 All right. So mostly content management stuff, which is really, really valuable and helpful. What do you do today? You work at Facebook, right?

03:57 Today I work at Facebook and I do very different things. I don't so much work on the website anymore. As you know, Facebook does use PHP for that. Strange language.

04:07 I work on the backend side, on the source control side where I hack on Mercurial, an open source project that lets you do development distributed source control.

04:16 Oh, that's cool. Yeah. So Mercurial is kind of a cousin to Git, similar type of source control. What's Mercurial written in?

04:24 Mercurial is written in Python.

04:25 Interesting.

04:26 Mercurial is a Python project. And because it's a Python project, we were able to make it scale. So Facebook, everything is turned to 11. Everything is crazy.

04:36 Everything is just over the top high numbers and skills over the chart. And to be able to follow all the developers and all the changes they make every day, we couldn't actually make Git scale there. We couldn't make Git follow. And Mercurial did follow.

04:50 So we can, because Mercurial is so written in Python and highly extensible and highly tweakable, we can make it work at the crazy levels that Facebook is at.

05:00 That's really, I'm sure that's so exciting to work at Facebook.

05:02 Absolutely. It's a great place to be.

05:04 Do you work remote or is there a place there in Cambridge?

05:07 I work in London. So I commute four days a week up to London to work and one day a week I stay at home.

05:14 How much source code does Facebook have? Is it like, so when you talk about scaling it, is it the number of people using the system? Is it the amount of data? What's the scale look like?

05:24 It's everything. So we put everything into one monorepo. Repo means that we try and put everything into one place, one repository, so that you can facilitate all the sharing and moving. And that really helps speed things up.

05:38 But at the same time, you can easily come into the file counts of six figures. So trying to get a full check out of that is not always the best thing you want to do.

05:49 So we have issues with the number of files, the number of directories, the number of commits each day, the number of developers that work on it. All those things play.

05:58 Yeah, I can imagine that. Wow. Yeah. And Google also does this monorepo thing.

06:03 This is a really interesting idea to me when you have that many files. Have you open sourced any of these tweaks or anything written about them?

06:12 Lots of this stuff is open sourced. So Facebook has a repository with their own extensions in there. They are not perhaps immediately something you can use, but there is a lot of inspiration there.

06:23 We also contribute straight back to the Mercurial project itself. Until recently, the founder of Mercurial, Matt McEll, worked at Facebook. He recently decided that after 11 years of Mercurial work, he wanted to do something different. So he moved on to other things. And the Mercurial project is now trying to make its way without him.

06:44 Wow. Yeah. So you had the guy there to help you build this up. That's really interesting. Let's talk about Stack Overflow. Maybe tell the world what Stack Overflow is. The one person who doesn't know it.

06:54 Stack Overflow is a site for programmers. And the goal here is to help programmers find answers to their common problems. It was born from frustration with forums. You know, the general forum where someone says that they had a problem with this code and can someone help them and 20 people pipe in, but that they have the problem too and they don't know the solution. And then maybe on page 15, someone has got the solution.

07:17 And then it disappears into a huge pile of posts about different things and you never find it back again. Stack Overflow is very much aimed at trying to surface the question and the answers. So you have just a question.

07:33 And people, they use gamification to get the best answers on the top. So the general idea is that people vote. This was a question that is worth, that is well asked, that is complete. And these are the answers. And this answer is the best because that gets the most votes on it. That's the idea is that you get an encyclopedia of knowledge, of programming knowledge.

07:53 And they, you know, Jeff Atwood and Joel Spolsky, the two founders, they have nailed that in some special way, right?

08:00 They found a secret sauce.

08:01 They found, they definitely found a secret sauce and it's working really, really well. Like pretty much any programming question you have, if it has technical detail to it, there's probably a Stack Overflow result in the top five Google results.

08:16 Exactly. For the most common programming problems, you will find a solution there.

08:19 Yeah. And it's not just, well, you should put this curly brace here or whatever. It's also, it's much deeper than that, right? I think, I think there's a lot of really interesting questions as we'll see.

08:31 Absolutely. Absolutely. There's such a wide range of things that answer there, provided you stay on topic, which is sometimes a little harder.

08:39 Yeah, it can be. But yeah, it's, and they're very, very much careful about making sure things stay on target and focused and don't rant and basically become the forum that they're trying to escape from.

08:52 So let's start.

08:53 Exactly.

08:54 Yeah. So let's start with what makes a good question on Stack Overflow. So I guess before you answer that, tell us, I was looking at your, your user profile and there's some pretty astounding statistics there.

09:07 So for people who know you have about 500,000, a little over 500,000 for reputation, but you have 16,000 plus answers. And it says you've reached 22.9 million people. That's really amazing.

09:21 The numbers, they keep on growing because I like answering. I like finding solutions to problems. It's, it is kind of addictive. It is addictive with the fact that the feedback that you get and the, the, you learn so much yourself from this.

09:35 I love finding the key to the problem. So if someone has a particular view on the problem, they have a certain idea about how things should work or not work. And they clearly don't understand something. And I love finding the key that helps them suddenly see, oh, that's why this is how it works. So I'd prefer not just to give you the solution. I also prefer to tell you why.

09:57 Yeah. I noticed that from your answers. Yeah.

09:59 In doing that, you learn yourself whether or not, you know why. And that helps me grow as a programmer as well.

10:05 Yeah. I think that's a really good point because it's one thing to say, this code doesn't run as I expected. You could say, well, change it to this and it would. It's another to say, well, the reason your code doesn't work is if you really look inside, like say the CPython interpreter, it's doing this. And when it does that, here's what it means. And so here's how you fix it. Like that, that both enriches the person's understanding, but yours as well, like you say.

10:31 Exactly. I get to learn and apply it elsewhere.

10:35 I can use this in my own daily life. My own work is informed by what I learned from answering on Stack Overflow.

10:42 Yeah, absolutely. I'm sure it is. I'm sure it is. Let's start with what makes a good question on Stack Overflow.

10:48 So Stack Overflow is very strict about what it accepts for questions. Over the years, we've learned certain things don't work. So certain things are not on the topic. Stay away from those certain things, like asking what is the best web framework?

11:04 What is the best is very subjective and it's very hard to answer without a lot more detail about what you're doing. Most people don't give that detail. And what then also happens is that the spammers come along, the people that have something to sell and they say, ours is the best.

11:17 So those kinds of things are off topic. The same thing for opinion-based things. And we don't want to go on. We don't want to end up writing books either.

11:28 So if you want to know about the best practices for using object-oriented programming and when to use one technique or another technique, that would rapidly be closed as too broad.

11:41 Now, once you narrow it down to very specific programming problems, then you already start being on topic.

11:47 And then what you definitely need to do is, first of all, realize that these questions are not just for you. We want them to be there for everybody. So someone else coming Googling later on, need to be able to recognize that they have the same problem.

11:59 And the other thing is that if you want answers, you need to help the people that answer you. So you want to show the context of research that you've done.

12:09 And you want to narrow down your program to the essentials. So if you come in and say, I have this XML document that I want to parse and get this information out and write it to a file, but I want to transform this information this way and that way.

12:22 How do I do this? You're going to end up disappointed.

12:25 Yeah. And the XML file is like a thousand lines long with all sorts of complicated stuff. And they haven't focused in on just the essence of the problem. They're basically like, solve this problem for me, right?

12:35 Exactly. So solve this problem for me. What you can do at such a point is you need to break this down into separate issues. Perhaps you already succeeded in loading the XML file and parsing it. You've already maybe made choices there. Tell us about those.

12:49 So now you've narrowed it down to perhaps only finding specific information in that file. Leave out the part where you're going to transform it and write it to something else. Those are separate problems. Those are separate steps.

12:59 And once you narrowed it down to one of these steps and show us what you put in there, what you expected to come out and what have it instead with all the error message and all the full traceback and everything that you can, that you see, then we can see it too.

13:14 And often you will come to a very quick answer.

13:17 Or it might be, again, I cannot emphasize this enough. You have to have done your research because it could be that the question was already asked before and answered before and your question will be closer to duplicates.

13:31 Yeah. So Stack Overflow is actually pretty good at helping with you find answers as you're kind of ignoring the fact that they might exist. I guess is the way to think of it.

13:41 We don't hate duplicates either. We don't dislike duplicates. The internet is, of course, very impersonal. You can't see the other person's smile or feel any warmth. So people often see this as a personal putting their question down thing.

13:56 And duplicates, sometimes people actually go, I'm sorry, I asked the duplicates. And to that I say, it's all right. Duplicates happen. You can't always know exactly what you're searching for. We can help with that.

14:09 And duplicates actually are valuable to Stack Overflow as well because what happens is that you now added more keywords for people to search on.

14:17 So when you created the duplicate, you asked the question. It was well asked, but it was a duplicate. Google still has indexed your question.

14:25 And when someone clicks on it on Google, we actually redirect new visitors straight to the canonical question that you were a duplicate of.

14:32 So at that moment, you have helped someone else find the same solution.

14:36 Oh, that's interesting. I didn't really think of it that way.

14:39 So the research part is really important. I suspect it really affects the way that you feel about answering the question.

14:46 If like somebody has just put zero effort or what appears to be zero effort into finding their solution and they're just like, I don't know, let's put it on Stack Overflow, see if somebody will do this for me.

14:56 Probably your willingness to give a good solid answer goes down, right?

15:00 There's a certain type, certain classes of questions that we've seen so many times now, so often asked, and there's so many times that there's a duplicate, these common errors, that some people may lose patience a little bit.

15:12 And then you get, haven't you done your research?

15:16 You could have found this in the first five results on Google.

15:19 Right. I took your title.

15:20 I put it into Google.

15:21 And here's the Stack Overflow answer that actually has 10 answers and 100 upvotes and whatnot.

15:26 Exactly.

15:27 Interesting.

15:28 So it is the same kind of thing.

15:30 I think there was a funny video online, what if Google was an actual person, where you see someone in an office and people come in and ask, how is baby formed to this person's face?

15:41 The person behind the desk being a comedian does a great job of looking frustrated or can't ask this question 100 times already.

15:49 Yeah, exactly.

15:51 Nice.

15:52 Okay.

15:53 So I think everyone's got a good sense of more or less what makes a good question.

15:58 Let's talk about some of the ones that you found that are noteworthy or whatever.

16:03 First of all, how many Python questions are on Stack Overflow?

16:07 Do you know?

16:08 Oh, if I look it up very quickly, it's about 650,000.

16:12 650,000.

16:14 650,000 questions today that have been tagged with Python.

16:19 There can be more.

16:20 There are several version-specific sub-tags, so Python 2.7 or Python 3.5.

16:26 And not everybody uses the main tag when they ask about a specific version.

16:32 Right.

16:32 It might be just tagged Django, but it would also count as Python.

16:36 There might just be Django-specific library questions, so Django, Flask, or Pandas, or NumPy, those kinds of things.

16:45 They're all Python questions, too, but they might like the tag.

16:48 So there might be more.

16:49 All right.

16:50 There probably are.

16:50 Yeah, it's probably a subset.

16:52 Okay, cool.

16:53 So you've, out of the 650,000-plus questions, chose a few that are really good.

17:00 And you said that some of the questions that are really interesting are these what questions.

17:06 W-A-T.

17:07 I think W-A-T.

17:09 This comes from a talk by a man named Gary Bernard, who did a very short and very funny talk about wah moments.

17:16 He goes, wah, completely memes.

17:19 Those moments where you go, it really shouldn't be doing that.

17:23 That is such a crazy response to the code.

17:25 Yeah.

17:25 Usually it is.

17:26 It's bugs or very obscure corner cases of the language.

17:30 They are, for me personally, the most interesting ones because they definitely will cover areas that I know nothing about.

17:40 Or very little about it.

17:42 If they make me go wah, then it's definitely something interesting.

17:45 Yeah, absolutely.

17:46 And depending on the language you're working with, there's more or there's fewer.

17:51 Like the example that Gary chose was JavaScript, which is full of wonderful watts.

17:56 Exactly.

17:57 Python, on the whole, is a very, very low watt count.

18:00 But there are a few, and usually they are due to bugs.

18:03 So Python is a very consistent language.

18:08 The developers do an awesome job of making sure that Python is a consistent and predictable language, unlike JavaScript or even few Ruby examples as well.

18:18 But there are a few of those.

18:19 Recently, very recently, I think last week, there was one question that was asked where someone built a set contains unique elements.

18:30 But if they built a set from a list, they got a different result than when they built a set from a set literal.

18:36 So they had multiple elements in it.

18:38 And they listed the elements in the same order.

18:42 But if you used a set literal, they got a different result from building a list first and then passing that to the set callable.

18:49 That should not happen.

18:51 That should not happen.

18:53 It shouldn't.

18:54 So if you say set, open parenthesis, and you pass an iterable thing, like a list or something, you get one result.

19:01 If you say curly brace, thing, comma, thing, comma, thing, comma, thing, close curly brace, and you put the same things in that you pass to your set initializer, you actually get different sets.

19:15 With the properly constructed inputs.

19:18 So at that moment, I definitely go, that shouldn't happen.

19:21 That is weird.

19:22 I'm intrigued.

19:23 I'm hooked.

19:24 And the next hour is going to be spent figuring out what's going on.

19:27 Where did it come from?

19:28 Why?

19:29 Why?

19:30 Why?

19:30 In this case, it was a bug.

19:32 It was a bug.

19:33 Okay.

19:34 And I'm looking at your answer here.

19:37 And of course, everybody who's listening, all these questions and answers will be added as links in the show notes.

19:42 So I'm looking at your answer here, and you're like, all right, so here I'm trying a few things, and we're trying to understand it.

19:48 And all right, let's just open up the disk module and do a straight disassembly on this thing.

19:54 Yeah, because at that point, you're going to have to dig in, what is the Python interpreter doing?

20:00 So you need the bytecode, and the bytecode is built from the source code, drives the interpreter.

20:05 And then you can start looking at the interpreter source code and see what is going on.

20:10 And for me, it was actually hard to figure out what was going on because I looked at the most recent version of Python from source control, so from the Mercurial repository.

20:20 And the bug had been fixed very recently as well.

20:24 So you used, if you do this with a release version of Python, you will not see the bug.

20:30 You will see the bug.

20:31 If you actually look at the source code as it is today, you won't see the bug.

20:36 I see.

20:36 And did you go to the source code to try to understand it?

20:38 Like, if I can do it?

20:40 I went to the source code.

20:41 It looks to me, my hypothesis is that the set literal is parsing these things in the wrong direction, in the wrong order.

20:47 That it's doing this in the wrong order.

20:50 But in the source code, I could see that it was parsing it in the right order.

20:54 So at that moment, I'm trying to figure out what is going on.

20:57 I could reproduce the issue.

20:58 It clearly wasn't matching what the code was.

21:00 So I actually went to search for issues in the bug tracker, found it, and then quickly realized that I was looking at a fixed version of the code because it already had been fixed.

21:09 So what was happening is that for all currently released Python versions, if you use a set literal, the stack is each element in that literal is pushed onto the stack.

21:21 And then the stack is taken in reverse to build the set.

21:24 So you always get the items from last to first added to the set.

21:28 Now, a set tests for equality.

21:31 So if two objects are test equal, even though they look different to you as a developer and there are different types, they still say that they are equal, then the first one in the set will win and will stay in the set.

21:43 And the other ones are rejected.

21:44 They were not added.

21:45 So in this specific case, someone was using zero and then the complex number zero, so zero j, and the instance of the decimal class from the decimal module, decimal zero.

21:59 And because the decimal module in Python 2 doesn't support equality tests with complex numbers, only with integers, it would test equal against zero but not against complex zero.

22:10 And so depending on the order in which they go in there, it would, yeah, change it.

22:15 Accept one or the other as being equal to what's already in there and rejected, and therefore you get different results.

22:20 Yeah.

22:20 Wow.

22:21 These are definitely corner cases.

22:23 These are obscure stuff, and most people won't come across these.

22:26 But that's the kind of question that I personally enjoy.

22:29 Well, one, really interesting to think about why that would even be possible and what's happening.

22:33 But also, you actually found a bug or the person found a bug, and you verified the bug, I guess.

22:39 In this case, I confirmed the bug.

22:40 Yes.

22:41 Exactly, exactly.

22:42 How often has that happened?

22:44 It doesn't happen that often.

22:45 And also for packages, there are bugs and corner cases.

22:49 Python is a pretty solid piece of software.

22:51 Usually, when I do find the bugs, they are usually very minor.

22:56 There might be documentation bugs, or one of the modules in the standard library might have some unexpected behavior that could be improved.

23:04 The fundamental issue, like the order of set literals being processed, that's pretty rare.

23:12 Yeah, I suspect most of the bugs that are found are up above the standard library.

23:17 They're in some external package or something like that, right?

23:20 Exactly.

23:21 So usually, if far fewer people look at it, it might be a different project that has a different standard for testing.

23:27 And so, more likely to find them there than I would find them in Core Python.

23:32 Yeah, absolutely.

23:33 Absolutely.

23:33 This portion of Talk Python to Me has been brought to you by Rollbar.

23:51 One of the frustrating things about being a developer is dealing with errors.

23:55 Ah, relying on users to report errors, digging through log files trying to debug issues, or a million alerts just flooding your inbox and ruining your day.

24:03 With Rollbar's full-stack error monitoring, you'll get the context, insights, and control that you need to find and fix bugs faster.

24:10 It's easy to install.

24:12 You can start tracking production errors and deployments in eight minutes or even less.

24:16 Rollbar works with all the major languages and frameworks, including the Python ones, such as Django, Flask, Pyramid, as well as Ruby, JavaScript, Node, iOS, and Android.

24:25 You could integrate Rollbar into your existing workflow, send error alerts to Slack or HipChat,

24:30 or even automatically create issues in Jira, Pivotal Tracker, and a whole bunch more.

24:35 Rollbar has put together a special offer for Talk Python to Me listeners.

24:38 Visit rollbar.com slash Talk Python to Me, sign up, and get the bootstrap plan free for 90 days.

24:44 That's 300,000 errors tracked all for free.

24:47 But hey, just between you and me, I really hope you don't encounter that many errors.

24:51 Loved by developers at awesome companies like Heroku, Twilio, Kayak, Instacart, Zendesk, Twitch, and more.

24:56 Give Rollbar a try today.

24:58 Go to rollbar.com slash Talk Python to Me.

25:08 The next one that you said was really interesting, and I agree, is it's so simple.

25:14 It's like eight or nine words, the question, but it has 3,200 upvotes.

25:22 And the question is, what is a metaclass in Python, and what do you use them for?

25:28 So this is, I think, is an example of a really awesome answer.

25:33 So I'm not talking about the one that's marked as accepted, but the one below it that has the most upvotes.

25:39 This is one user that has learned that for certain subjects, it is worth it to write an essay, to write a full answer.

25:45 And his name is Isetus, and his answer for metaclasses is absolutely epic.

25:51 This is why we have Stack Overflow.

25:54 This is what needs to flow to the top.

25:57 Metaclasses are an unfamiliar concept to most people.

26:01 Metaclasses are the type that creates classes.

26:05 So classes are a factory, a thing that you use to make instances.

26:10 But what makes classes?

26:11 Now, that's a metaclass.

26:13 Metaclass can produce a class.

26:14 It can be a mind-boggling and hard-to-grasp concept.

26:19 But Isetus does an absolute marvelous job of explaining this anyway.

26:26 So he starts with explaining what classes are, what objects are, and this goes deeper and deeper and deeper and includes not only what metaclasses are and how they work, but also includes excellent advice as to when you want to use them, which usually is not.

26:42 But when you do need them, when you do need them, metaclasses are a very powerful concept.

26:45 And he does, I think, one of the best jobs of explaining that.

26:49 Yeah, it's like a little book chapter almost that he wrote.

26:52 I think it's like 15 pages, you know, based on my screen size or whatever.

26:56 That's pretty impressive.

26:58 And I really do think it's a great answer.

27:01 Yeah, metaclasses are definitely interesting and useful.

27:04 But I think we mostly consume them, right?

27:06 More than create them as average, everyday programmers.

27:10 Average, everyday programmers, you mostly consume them.

27:12 Most people don't know that they even exist.

27:14 This is something that frameworks use.

27:17 The Django framework or the WT forms framework use metaclasses heavily because they get to have access to all the attributes you just set on a class and transform them and manipulate them and make them do something magic.

27:30 Yeah, I was thinking of SQLAlchemy's declarative base.

27:33 Yeah, SQLAlchemy is very similar to that.

27:36 Again, it's a model where each of the fields defines something about the model that is a little bit more than just the object you just put in there.

27:45 So define a class that also models the columns in a table.

27:49 You usually want those attributes to behave differently in different contexts.

27:53 Like when you are creating a new instance or you are just putting stuff in from the database, that moment, that class has to behave differently.

28:01 And that complexity, it can be neatly encapsulated and hidden by using a metaclass.

28:07 Yeah, it's really, really wonderful.

28:09 Awesome.

28:10 Okay.

28:11 How about accepting, next question.

28:14 Accepting the user input until you get a valid response.

28:17 Yeah.

28:17 I picked that one because it's a very good example of, again, what the Python community around Stack Overflow does.

28:24 So Stack Overflow itself is a site, but next to that we have a chat site as well.

28:30 So there's a chat.stackoverflow.com where there's various different rooms where people, members of the community come together to hang out or to chat about all sorts of weird things and sometimes even about Python.

28:40 And there's a Python chat room.

28:41 And because people talk about and are connected to Stack Overflow, that room sees lots of patterns happening.

28:50 So questions that keep coming up, certain problems that keep coming up.

28:53 And there's sometimes a class of them.

28:55 Like using raw input or input in your Python program to get a response from a user.

29:02 Most homework starts with take an integer from the user and put it into something.

29:09 And that is something many new programmers fall over and keep stumbling into.

29:15 So this particular question was written by a member of the Python chat room together with an answer based on their experience helping people again and again and again with the same issues, the same related issues.

29:27 What do you do to validate that input?

29:29 What do you do when the user has got it wrong and you want to repeat it?

29:33 All the pitfalls all collected into one place and as a self-answer.

29:37 So this was both the question and the answer have been written by one person at the start and then refined later on by the members of the community.

29:45 Interesting.

29:46 So this one, they made the answer, their own answer, a community wiki.

29:51 Exactly.

29:53 I've seen that you can make an answer a community wiki or you can sort of keep it to yourself and you get reputation if you keep it to yourself and you don't on a community wiki.

30:04 You want to talk about that?

30:05 Exactly.

30:05 Yeah.

30:06 The community wiki is definitely aimed to be able to lower the bar of improving a post.

30:13 So in this case, the community definitely felt this is something we as a community want to do because it's pretty much needed and it's too scattered around the site.

30:20 And we don't want it to be owned by one person specific.

30:24 So you should feel more, you should feel freer to actually edit this and improve it.

30:29 That's why it's made a community wiki.

30:30 And the moment you actually then invite more people to edit it, then you don't no longer know who can earn more than other people if there's upvotes on this.

30:40 So that's completely taken away.

30:41 Yeah, that makes sense.

30:42 Also see that it's protected.

30:44 The question is protected.

30:46 What does that mean?

30:46 Yes.

30:47 That is just something, a trick we use as moderators.

30:50 But high rep users can do the same thing.

30:52 When a post like this becomes so very popular, what can happen is that lots and lots of new people, so people with low reputation come in and go,

31:02 my solution is unique.

31:03 My solution is unique.

31:04 And they don't have the experience to actually see that their solution is perhaps not that unique.

31:09 Or they say, I don't quite understand.

31:11 They don't quite understand yet how Stack Overflow works and they don't understand the answer.

31:16 So they might post in an answer below it another question where they request that someone explains how the whole thing works.

31:23 Well, answers are not questions.

31:25 So that is the wrong place to post this.

31:28 So a question like this can attract lots of those kinds of answers.

31:33 So if I have enough reputation that I can see not only the answers that are posted, which currently says 10 at the top, but most people can only see the first three, four, six posts.

31:47 So there's four more on that same page that have been posted before that are either someone not having understood that their solution is not unique and that they have basically repeated the same thing or explained it wrong.

31:57 Or are questions.

31:59 This one doesn't work.

32:00 How does it?

32:01 Yeah, interesting.

32:02 So what kind of powers do you get as you go up in reputation there?

32:07 Full disclosure, my reputation is like 2,000.

32:09 I've answered some questions.

32:11 I've asked some questions, but nowhere near that I would have any of the exposure to the stuff that you get.

32:16 There's quite a wide range of things that we can do.

32:19 Mostly what we like to see is that people start, when you start getting invested in Stack Overflow and you start gaining reputation, you get experience with how things work and we trust you more and more.

32:30 And at that moment we can rope you in to help.

32:32 So a lot of these, once you get past the initial kind of points where you can start voting and start adding comments, which before to keep spammers out, don't give you to you immediately.

32:44 You start getting into what we call community moderation privileges.

32:48 So you can start helping the electric community moderators keep the site clean.

32:54 Most of the site is kept clean by the community.

32:57 So you can start doing like, you're allowed to edit posts at 2,000 points.

33:02 We allow you to edit posts without review.

33:05 So you can go to any other posts and start fixing things.

33:09 If you see a typo, fine.

33:10 You have 2,000 points or more.

33:11 We trust you that you can make that change.

33:14 At some point you can start helping gardening the tags.

33:18 The tags could be marked as synonyms of one another, say.

33:21 The Python tag has got several synonyms.

33:24 Like Pythonic was not seen as something that needed a separate tag.

33:27 It's made a synonym of the Python tag.

33:29 At 2,500 points you can start helping with that.

33:32 And then you can start helping close posts or put them on hold.

33:35 And also reopen them again if you feel that it shouldn't be, stay closed.

33:38 Maybe it was improved and fixed.

33:40 So now you can reopen it again.

33:41 Tag wikis, the things that we keep a bit of documentation about each tag.

33:45 Is it called a tag wiki and that's that?

33:47 At some point you're allowed to edit those without review as well.

33:50 Et cetera, et cetera, all the way to 20,000 points.

33:53 And that's the highest amount of, oh no, sorry, 25,000 points.

33:58 It's the highest level that you can get to.

34:00 And we give you access to internal data, site statistics.

34:04 Because then we think you're so invested into this, you really want to know how well we're doing.

34:07 That's really cool.

34:09 Yeah, and you're a little bit past 25,000 these days.

34:12 So you've had those privileges for a while.

34:14 But that's really great.

34:15 I think I might be a little past this, yeah.

34:18 Exactly, like 400, I don't know, hundreds of thousands past that.

34:22 That's awesome.

34:23 So another question that you put up here has to do with creating type level variables

34:28 and trying to initialize one of them with a list comprehension from another or something like this, right?

34:36 Yeah.

34:37 This is one of those wah moments, again, where I learned such a lot about the Python programming language,

34:43 about how scopes interact, but also a little bit about how the Python developers definitely see the language as something living

34:51 and will make changes if that makes sense.

34:54 So in this case, this is a weird interaction between scopes for classes and functions and list comprehensions.

35:02 Now, normally when you have a function, that's a scope, and we have the global scope.

35:08 So we have a local and a global scope.

35:09 The things are simple.

35:11 You just have functions.

35:12 But as soon as you start nesting functions or you start using functions in classes, you introduce more scopes,

35:18 and you have to start figuring out how you access names that exist outside of the function.

35:23 So normally in a function, if you use a global, it is available because it can be found in the global namespace,

35:30 and that's part of the normal search.

35:31 But as soon as you start using classes, a class object is also a scope.

35:36 So the class definition of building your class object has a separate scope of names,

35:42 and different rules apply there.

35:44 Let's say you have a class that defines a class attribute, and then you define a method in that.

35:50 The class attribute is not a parent scope, and it's not available to the function in the class

35:55 because you normally would bind that function as a method, and then you work with an instance over the class,

36:00 and there might be multiple of these.

36:01 And therefore, you need to separate out the lifetime of the instance in the class,

36:06 and defining it.

36:08 So the names in a class scope are not normally available to the functions that you define inside of the class.

36:15 That comes later.

36:16 You can access those via the class object that has been created.

36:19 How does it play with list comprehensions, you ask?

36:22 Well, the Python developer started with seeing list comprehensions as very simple constructs,

36:29 no different than a for loop.

36:31 If you put the for loop in a function, all the names you use in that for loop,

36:35 including the target for the iteration.

36:38 So the for name in an iterable, each time you iterate through the for loop, the name that you've used for that gets assigned the next value.

36:48 And it's in the sequence.

36:51 That name lives in the same scope everything else lives in for that function.

36:56 So this is the local name.

36:57 So after your for loop is done, you see that local name, and you can still access it.

37:00 So for i in range 10, you'll make your loop run from 0 to 9.

37:04 At the end of it, i equals 9 is still available to the rest of the code.

37:08 List comprehensions were seen exactly the same.

37:11 Just a local thing in your scope.

37:14 So the for loop target of that is available.

37:16 The Python developers then next created generator expressions.

37:20 A generator expression is evaluated lazily.

37:23 So you can sort of see it as a function.

37:26 You first create it.

37:27 It is an object that will behave in a certain way, but only when you make it to later on.

37:33 So you deferred execution.

37:36 Right.

37:36 So if you want to try to, say, access the iteration variable in a generator, a generator expression,

37:42 it may have been created, but it may not have been created, depending on whether you've actually executed the generator, right?

37:48 Exactly.

37:49 So you actually, at that point, you have executed your generator.

37:54 So these variables don't even exist yet.

37:56 So generators were given a hidden function scope.

37:59 They behave just like functions.

38:00 Everything inside it is local to a new function, and that's hidden.

38:04 So that you can execute it just like a function.

38:07 And then the local variables are part of the generator object, like a function would be, and are cleaned up separately once a generator object is done.

38:16 And the Python developers, as they built this, then realized that this also really applies to list comprehension.

38:23 This comprehension and generator expressions are just basically the same thing, except one of them is immediately executed.

38:28 The other one is deferred.

38:29 So in Python 3, list comprehensions were given in scope 2.

38:33 Now, why is this important?

38:34 I always talked about how classes have a scope, and then the methods in the class can't access the class scope.

38:41 They will have to go for the class.

38:42 This applies to generator expressions and list comprehensions too.

38:46 Well, at least.

38:47 So they do it in Python 3.

38:49 In Python 2, where list comprehensions are still sort of simple things without their own scope, that behaves differently.

38:55 So there was a discrepancy there between Python 2 and Python 3 where things changed.

39:00 And most of the time, people write simple classes and write class attributes and write their methods.

39:07 And they don't think about trying to access things that they just defined for class attributes.

39:12 But when you're writing, say, a list comprehension to make an attribute of your class, it's certainly very surprising that you can't access anything else you already defined for that class.

39:22 Because it's a scope that is not available to you.

39:24 I think this is a really interesting example of understanding why this was changed.

39:30 Do you know if the Python core developers are paying attention to Stack Overflow and possibly making changes to the next version of Python based on things that appear there?

39:41 Or does it have to bubble up farther through some other channel?

39:43 Stack Overflow is one of the inputs, one of the sources where you see there's a long tradition of the Python developers looking at how Python is used.

39:52 There's a longstanding mailing list called Python Tutors where you can ask questions and people will answer those.

39:59 It's like a mailing list forum that answers Python beginner questions.

40:05 And I have seen plenty of evidence that that source over the years has already informed the core developers on how they do things, that they see these common problems.

40:15 A lot of the core developers are themselves consultants that teach Python, teachers or consultants that help companies use Python better.

40:22 And they use those inputs too.

40:25 And Stack Overflow is just another input in that way.

40:27 So I definitely think that they're using it.

40:30 I know that several of the Python core developers are regularly answering on Stack Overflow as well.

40:35 So they definitely get that input too.

40:38 Yeah, that's great.

40:38 I'm sure they are.

40:39 But this type of question seems like it can really clearly pull out some of those decisions.

40:47 And maybe if it came earlier, before that was changed, maybe highlight some of the problems.

40:52 Exactly.

40:53 Exactly.

40:53 This portion of Talk Python to Me is brought to you by GoCD from ThoughtWorks.

41:12 GoCD is the on-premise, open-source, continuous delivery server.

41:16 With GoCD's comprehensive pipeline model, you can model complex workflows for multiple teams with ease.

41:23 And GoCD's value stream map lets you track changes from commit to deployment at a glance.

41:29 GoCD's real power is in the visibility it provides over your end-to-end workflow.

41:34 You get complete control of and visibility into your deployments across multiple teams.

41:39 Say goodbye to release day panic and hello to consistent, predictable deliveries.

41:44 Commercial support and enterprise add-ons, including disaster recovery, are available.

41:48 To learn more about GoCD, visit talkpython.fm/gocd for a free download.

41:54 That's talkpython.fm/gocd.

41:58 Check them out.

41:59 It helps support the show.

42:08 Speaking of newer versions of Python, the next question is, why is Python 3's super function magic or super method?

42:16 Yeah, but this definitely came also from feedback on how things work and don't work for Python.

42:21 So the super function, I'm going to introduce it real quick, is the way that you can access methods on parent classes.

42:31 So when you override in a subclass a method and you still want to use the functionality of the original, you can use super to access methods on classes in your method resolution order.

42:44 So the linearization of all your base classes.

42:50 The linearization means that we put all your classes in a specific order and that order is always fixed and predictable.

42:56 So when you create a subclass and you want to put an under-under init method in it and you want to initialize a few more attributes that your more specialized subclass uses,

43:06 but you still want to use the original init method that you use super to get there.

43:10 Now, the way Python inheritance works, I already mentioned the method resolution order.

43:16 You want to be able to find which class is next in line so you can call its init methods.

43:23 When you're using multiple inheritance and diamond patterns, it's not always that clear, but Python solves that for you.

43:28 And so you don't have to worry about it if you use the super method because it will take care of finding the next class for you.

43:35 Right, there's a predictable, well-known order in which it will search for the thing you're trying to call on the super, yeah.

43:41 Exactly.

43:42 So we call it the method resolution order.

43:46 That's the order in which the next one will come about.

43:48 But for a super to be able to know where it is, because your class could be subclass and subclass and subclass further,

43:56 for it to know where on the method resolution order for the current object,

44:03 because that matters, it's not just the current class, it's for the current instance that may use a subclass,

44:07 it has to know where on that line you are at this point, this method.

44:13 So if you have a foo.unit method and you want to call the next one in line,

44:19 you need to tell super, I am foo.

44:22 So you can search past that point.

44:24 You can find foo in the line of other classes in the whole method resolution order

44:28 and find the next one in line.

44:30 So just like your current type, the type of object you are, isn't enough because you could have called down into some intermediate level of inheritance,

44:38 which is then calling super or something that can get really complicated, right?

44:42 Exactly.

44:43 Foo could have been subclassed by bar and bar could have called foo.unit via the super trick.

44:49 And then self, the type of self is bar and therefore you can't use that.

44:53 You can't say type of self is bar and therefore I'm going to start searching from there.

44:57 Because you're no longer in the bar class, you're now in the foo class.

45:01 So you explicitly in Python 2 have to tell it, start searching here.

45:06 That's the first argument is the current class.

45:09 Second argument is the current instance.

45:11 So you can find the MRO from that.

45:14 That means you constantly are repeating yourself.

45:17 So you're writing a class foo.

45:19 And then in all the methods that need to use super, you keep saying, this is class foo.

45:24 This is class foo.

45:25 This is class foo.

45:26 So that violates the do not repeat yourself principle, the drive principle.

45:29 Then there are other tricks in Python, like using a class decorator or simply storing your class in a different name.

45:37 Classes are objects, so you can use a new variable, a new global variable, call it spam and assign foo to it.

45:44 And then you can call spam and suddenly it is called spam.

45:47 So you cannot also at that moment guarantee that the old name still exists.

45:51 So what might happen if you have a class foo and you use super foo everywhere in there?

45:57 It may be that at the moment that you call foo on the internet, the class is no longer available under the name foo.

46:05 It might be called something different or something else might have been assigned to foo.

46:09 So now you have a problem because when you created the class, it was called one thing and now it's called something else and the names no longer match.

46:16 And then you have problems.

46:17 Yeah, absolutely.

46:18 So super, super, super, super tied to the class existing on underneath the same name.

46:26 And you have to constantly repeat yourself.

46:28 So the Python developers tried full, long and hard as to how they were going to solve this.

46:33 How can they avoid having to repeat yourself?

46:36 And how can they avoid record, somehow record the current class on which you just define this method so that it is no longer depending on the run, on runtime circumstances where the class still is available in the same name.

46:51 And that's where Python 3 super comes from, where you no longer have to pass in anything anymore.

46:57 You call super without arguments.

46:59 And that moment, something magic happens.

47:02 And that magic, some people feel, goes against the grain of certain Python principles.

47:09 Like there should be obvious things happening.

47:13 That Python is very explicit about what it does.

47:16 As Tim Peters once said in a very famous little recorded Python philosophy, there should be one obvious way to do it.

47:25 And explicit is better than implicit.

47:28 Super in Python 3 is implicit.

47:30 When you don't pass in arguments, it implicitly finds its arguments.

47:33 So that's why people call this magic.

47:35 But the reason why they're doing it is to avoid having to repeat yourself.

47:39 There's a lot of extra things going on in the hood in that when you create a method in a class, then a closure is created specifically for it.

47:49 So it is as if the function has been defined in a context where the name under class is available in a parent context.

47:57 Basically, it means it captures its setup when it gets created.

48:02 And then it can't really be influenced from the outside.

48:06 It can no longer be influenced from the outside.

48:08 And you no longer have to repeat yourself and passing it in.

48:12 It was also a common source of problems, a common source of errors where people misunderstood what needs to be passed in.

48:18 I already said you explicitly have to call, name foo and not take the current type of self because that may no longer be foo.

48:26 There might be a subclass.

48:28 And at the time, I did a search on code search engines and found tens of thousands of errors of people passing in either self.

48:36 On their class or passing in type self, thinking that's good enough.

48:41 I don't have to repeat myself here and type foo again.

48:44 I'll just take it from self.

48:46 And that leads to problems because when you have a subclass that also uses super, you get an infinite loop.

48:53 Because then you say foo is subclass to bar, bar calls foo, and then foo passes in bar each time.

49:00 And therefore, you go back up in the circle and we keep calling the same thing.

49:05 Do you actually get a stack overflow exception?

49:07 You get an infinite recursion error.

49:09 Okay.

49:09 It protects you from stack overflow.

49:11 Yeah, good.

49:12 Nice.

49:14 All right.

49:14 So that is really cool.

49:16 And, you know, I think what's really interesting is as you, you know, as you mentioned in the beginning, but as we go through these, it's really clear how it's what you learn by going through this exercise of reading the question, the answer or answering it yourself.

49:29 It's not just what is the question, what is the answer, but there's so many additional things and techniques and practices that come through.

49:37 I think it's great.

49:38 I really learned to understand what the decimal due does and how that works and how the Python evaluation loop works purely from answering on stack overflow.

49:47 Yeah, I can see that.

49:49 All right.

49:50 So another one is about Python 3's range objects.

49:54 Really two questions and sort of relative to Python 2's, which just turns them into a list of the things, a list of the integers.

50:02 Yeah, so Python 2, you have range, which is just a function that produces a list of integers and x range, which is a separate object that models the sequence, but it's quite simple and it's quite limited.

50:15 Python 3, they renamed x range to range because you don't really need that as a function.

50:19 You can just call list on the range object and then get the same results.

50:24 So range in Python 3 is a separate sequence object.

50:29 And I love the object.

50:30 I think it's a great idea.

50:31 I wonder why it took so long to make this such a first class object and to make it something that is part of Python core the way range is now in Python 3.

50:41 Ranges are very lightweight.

50:43 You just tell it, this is the start, this is the end, and this is the step size, how we get from start to end.

50:49 And that's all it records.

50:50 It doesn't need to know all the numbers in between because you can very quickly just calculate those.

50:56 If you know that you start at 1 and you end at 10 and your step size is 2, then you know that 3 and 5 and 7 and 9 are all part of that sequence.

51:07 You can just calculate that, right?

51:09 It's just math.

51:10 So why would you have to keep that in memory?

51:12 So most people still don't realize that range objects are smart like that.

51:17 So you do see lots of questions about them.

51:20 These are two example questions about someone being surprised, so surprised that if you make the range really large, you think that if you start at 1 and you put the endpoint at 10 million, that's numbers, right?

51:32 The human mind will see that that's 10 million numbers in that object.

51:37 That must take a lot of memory.

51:38 That must be really slow to figure out whether or not the number 10 million and 1 is part of that range.

51:44 But it isn't.

51:45 It's just math.

51:46 It's very easy to calculate.

51:48 Yeah, and it gives you a good look inside it because the person asking the question says, well, I could write one with generators and yields and so on.

51:56 But it takes it forever.

51:58 And so your answer to it was basically, well, let's look at the actual implementation.

52:04 And it's not just something that generates a sequence but can be smarter.

52:09 Like it can implement dunder contains and get item and lend and all these different things that have actual.

52:14 It behaves just like other sequences, just like lists and tuples and strings.

52:18 You can ask for any of the elements at any point in that range, but it doesn't have to keep them up front.

52:25 It can calculate them as you need them.

52:26 Yeah, yeah, that's cool.

52:28 It's really, again, a really nice look inside of things.

52:31 And I guess the last example we want to look at is about the order or lack thereof for sets and dictionaries, which is slightly changing, right?

52:40 That's exactly what's happening.

52:44 For many beginners, it is surprising that collections like dictionaries and sets don't have a set order.

52:50 There's an implementation detail of how Python has implemented dictionaries.

52:55 And that comes from – it usually happens to people also new to programming.

52:59 So they don't just come to Python as new and as the first thing that – it's also usually the first thing that they come to as a programmer, to programming in the whole.

53:10 Because if you, for example, have done systems programming in C or C++, most people that come from that kind of bank account already realize this.

53:18 But to make a dictionary efficient, so to be able to map a key to a value, you want to be able to store this efficiently and quickly find things.

53:30 So once you start working on this, you realize that it looks like there's an order, but the dictionary can't promise any order because the order that the keys are put in is just a property of the storage medium that we put things in.

53:44 Because we are putting a bunch of keys into a much smaller space and then quickly being able to find if a key exists or not in such a table.

53:55 Because we base this on what we call the hash, the property of any of these keys to be reduced to a simple number.

54:02 Explaining that is surprisingly often needed.

54:06 Once people understand it, they can – oh, okay, right, fine.

54:09 And we can go to another type and we can point to things like the order dict that also exists in Python.

54:14 Or tell them that in Python 3.6, the implementation changed.

54:18 So now dictionaries actually do remember order just because someone found a more efficient way of building the same kind of data type.

54:27 So Python 3.6 makes dictionaries ordered, not because everybody wants them to be ordered, but because it was a more efficient way of storing information.

54:37 Python 3.6 makes dictionaries an order of magnitude smaller in certain cases.

54:43 And that's actually super important because that's in some sense the backing store for all instances of objects.

54:49 Exactly.

54:49 Yeah.

54:50 Exactly.

54:50 Lots and lots and lots and lots and lots and lots of stuff in Python uses dictionaries.

54:54 So you can end up with quite a number of those.

54:57 So making them smaller is a very good idea.

54:59 Yeah.

55:00 So this question is really like you need to understand data structures to understand what is happening here because it doesn't make sense.

55:08 Like, well, why wouldn't I just want it to have the order?

55:10 But of course, you know, at least the older implementations, you want it to be fast more than you want it to be other order.

55:16 Exactly.

55:17 And it also helped implement a few other new things in Python 3.6 like the keyword argument order can be important in certain cases or the class attribute definition order can be important in certain cases.

55:29 And they are now as a property of this new dictionary implementation also implemented.

55:34 So suddenly when you create a class, all your attributes are kept in the same order that you define them, which can help form building libraries, for example.

55:44 Yeah.

55:44 Yeah.

55:45 Currently, you have to do crazy tricks to make keep it order.

55:47 Yeah, absolutely.

55:48 Absolutely.

55:49 And MongoDB, for example, has its own dictionary type thing because it doesn't want to reorder and entirely rewrite big parts of stuff.

55:58 And there's a lot of areas where this order actually would be kind of nice to have.

56:02 So very cool.

56:04 So those were some great questions.

56:06 And I feel like I've really learned a lot.

56:08 I hope people have as well just hearing you talk about them.

56:11 But why – like this is a lot of work.

56:14 Why do you contribute so much time and energy to Stack Overflow?

56:17 I already mentioned that I learned a lot from this.

56:19 I didn't start Stack Overflow because I wanted to learn so much.

56:24 I started because I was part of the Plone management community.

56:27 And we discovered Stack Overflow early on as a good idea to support people that wanted to learn about Plone and wanted to use Plone and then sort of fell into answering Python questions as well.

56:39 But I've since heard in an interview with another Stack Overflow numinary and creator of the C Sharp compiler, Eric Lippert once had an interview, I think, with Stack Overflow actually, giving his reasoning as to why he started with Stack Overflow.

56:57 And answering questions.

56:58 And that a manager actually told him that he should become an expert in certain things.

57:04 It would be helpful for him to become an expert in a certain subject.

57:07 And that the best method of becoming an expert in anything was to find a source of questions and start answering them.

57:15 Because then you really discover all the things you don't know yet and start learning those yourself to try and be able to answer these things.

57:24 And that really resonates with me.

57:25 That's really why I'm answering on Stack Overflow so much.

57:29 It's because it keeps teaching me new things.

57:33 It keeps pushing me into new directions and new areas of expertise that I didn't know I could do before.

57:40 Yeah, that makes a really… I really enjoy that.

57:42 Yeah, that makes a lot of sense to me, your answer there.

57:45 About the expert especially.

57:47 I think one of the things that makes somebody an expert is not that they've sat down and done programming for five years or ten years or whatever.

57:55 It's really how you spend that five or ten years.

57:58 If you just do the same thing over and over and don't run into many challenges and don't force yourself to continue to dig deeper, then you're not that much more of an expert than what you learned in the beginning.

58:11 But it's more the challenges and the problems and the edge cases that have hit you.

58:16 And I feel like Stack Overflow is that concentrated.

58:21 Yes, and it is a constant source of new challenges.

58:24 And in that way, it can be sort of addictive as well.

58:28 So you have to be careful.

58:30 I'm sure.

58:30 So speaking of addictive, what if I was really convinced that 2,000 for my reputation was insufficient and I decided the next week I'm going to take eight hours a day and just start answering questions and asking questions and just going crazy?

58:45 Obviously, my reputation would go up, but would there be other effects?

58:50 Would people start contacting me for jobs?

58:53 Like, hey, I saw you're doing great on Stack Overflow.

58:56 And answer these questions.

58:57 Do you want to come work for us or things like that?

58:59 People have used my Stack Overflow presence as a reason to contact me.

59:04 But I think that's not really the norm.

59:06 So I'm also looking at this from the point of view of hiring people.

59:11 How would I use Stack Overflow?

59:12 If I see someone that has a better reputation of Stack Overflow, that it works just like a blog.

59:18 It gives me a great insight into how you think and how you work and how you look at code and how proficient you are in those things.

59:27 Because you have this body of things out there that we can look at.

59:31 Or just like open source work, open source projects that you did.

59:33 A Stack Overflow profile with a good body of answers can be a real asset to let potential employers know that you know your stuff.

59:44 That you know a thing or two about what you're talking about because you can actually demonstrate this.

59:48 Which can give you a huge advantage because a lot of times people applying for jobs can't demonstrate their skills.

59:54 Exactly.

59:54 Exactly.

59:55 So Stack Overflow is actually really building on top of this because they give you ability to develop your CV or developer stories they call it now on the site.

01:00:06 And that they actually have a nice site business or actually their main business next to it to get employers connected with those people that have filled in a profile there.

01:00:17 Right.

01:00:18 The whole Stack Overflow careers thing, right?

01:00:19 The whole Stack Overflow careers thing.

01:00:21 And that does give you a lot, can give you a lot of insight into people how they work and how they think and see code.

01:00:28 So up to a certain level, getting answers on Stack Overflow, provided you, of course, know your stuff a bit, can help you there.

01:00:35 If I see someone with my level of reputation, I would start asking, are they spending too much time there?

01:00:42 Will they actually do work for me or will they just come to work and answer Stack Overflow questions?

01:00:47 Interesting.

01:00:48 I said, keep people interested, right?

01:00:51 Yeah.

01:00:51 You would learn a lot, I think.

01:00:54 If you seek out questions, there is such a thing, it's the fastest gun in the West where someone already knows the answer, can type faster than you and gets the first answer in and then that gets upvoted.

01:01:05 So if you're in it for the reputation and the upvotes, you're going to have to wait a little while because you're going to probably be a little slower than the experienced hands, the people that can type out the answer quickly.

01:01:17 Sure.

01:01:18 But at the same time, at that moment, you can compare your answer to theirs and see, did I miss something?

01:01:24 Did I miss a detail?

01:01:25 Did I miss a trick?

01:01:27 Did I use something interesting out of the standard library that I didn't know about yet?

01:01:32 So next to that, you're having to figure out how I'm answering this.

01:01:36 Do I know the answer?

01:01:37 You also get to see how other people are answering.

01:01:40 So that's something different than you're trying to find the solution to a problem you have.

01:01:44 You are actually looking at new questions as they come in and see how other people are answering them at that moment.

01:01:49 It's a slightly different angle.

01:01:51 You get to see how other people think about their problem.

01:01:53 And you might learn a thing or two about that.

01:01:55 Okay.

01:01:56 Very interesting.

01:01:56 I probably won't take a week and go work on Stack Overflow, but it's interesting to think about what would happen if I did.

01:02:02 It is certainly an interesting thing you can do for half an hour when you're maybe waiting for the bus or something like that.

01:02:07 Yep.

01:02:08 Absolutely.

01:02:08 All right.

01:02:09 So let me ask you one final Stack Overflow question.

01:02:12 And I've seen a couple of articles lately that felt like Stack Overflow was unfriendly to beginners or to newcomers.

01:02:19 And you had an interesting thought on that.

01:02:21 There's two angles here.

01:02:22 First of all, there's often a mismatch of expectations what Stack Overflow is for.

01:02:29 Stack Overflow is often seen as a personal help desk, something you can quickly put a question on and they'll help me fix my problem.

01:02:39 And then get upset because their question might get put on hold or downvoted because they didn't meet the expectations of what Stack Overflow has, which is to build a knowledge base, to build a repository of good questions and even better answers that help future visitors.

01:02:57 So if you forgot to explain what inputs came out of it or what the full error message is or you show a clear lack of having actually done the research about how to solve your problem, then you might actually find Stack Overflow very disappointing.

01:03:15 And then there's the other thing is that people say that Stack Overflow is only for professionals and not for newcomers and for new people, newbies new to programming or new to our programming language.

01:03:25 Again, that's not true.

01:03:26 It's usually what happens at the same time is that people are new to asking questions and they don't know how to ask a good question.

01:03:33 And that then really fires back on them.

01:03:36 So, and then there's, of course, the fact that because we are trying to, Stack Overflow is so hugely popular, we get maybe a few thousand of such people come in every day and asking questions.

01:03:49 So the community, on the other hand, is running out of steam and running out of power to keep helping each and every one of those learn about Stack Overflow.

01:03:56 So a lot of people don't get the hand-holding that they might expect.

01:04:01 Well, I'm new to this site.

01:04:02 Why didn't you tell me?

01:04:03 Well, Stack Overflow tries to automate this, tries to give you the help up front.

01:04:10 You get a lot of information about how to ask a good question.

01:04:13 There's lots of information in the help center.

01:04:15 But when you have a programming problem and your homework is due tomorrow, not everybody will reach that.

01:04:19 And then they skip by that very quickly.

01:04:22 And then what they see is what...

01:04:25 Yeah.

01:04:26 I feel a huge difference based on whether or not the person is legitimately trying to solve the problem and needs help or if they're just being lazy.

01:04:34 You know?

01:04:34 I do want to avoid the term lazy.

01:04:36 It is often just a misunderstanding.

01:04:38 And a certain sense of urgency can...

01:04:42 Because you have this problem and you're so into this problem and trying to solve it that you can forget to see the larger picture around it.

01:04:50 It's not necessary that you're being lazy always.

01:04:53 Sometimes there are lazy people that do post their homework on the site or even their exam questions as they sit in the exam.

01:05:02 I have literally seen posts where that consists of nothing more than a photograph of a paper that's clearly taken underneath the desk.

01:05:12 No, no, this is not an exam.

01:05:14 This is a trial question.

01:05:17 But can you give it to me in the next 10 minutes?

01:05:21 I'm going to need that before 9 o'clock because I've got to turn this in.

01:05:24 I'm going to turn this in.

01:05:26 Some people are lazy but most people just don't understand what makes a good question and why Stack Overflow is there.

01:05:36 And that clash can lead to frustration.

01:05:39 Yeah.

01:05:39 So I think this conversation has definitely helped everyone who's listened to it understand what makes a good question and so on.

01:05:47 So hopefully we've done a small part to reduce the frustration on both sides, the people answering the questions, being frustrated with the unprepared homework folks coming in.

01:05:59 I guess we'll leave it there for Stack Overflow.

01:06:02 But, Martin, that was very, very interesting.

01:06:05 And I think reading through your answers and other people's answers and questions is definitely enlightening.

01:06:12 Thanks for the work on that.

01:06:13 That's cool.

01:06:13 Before I let you go, two final questions I'd always ask my guests.

01:06:17 First of all, favorite PyPI package?

01:06:19 What would you recommend to people out there that they might not know about?

01:06:22 This is one I discovered.

01:06:23 Someone else used it in an answer and I love it.

01:06:26 I have been using it ever since.

01:06:28 It's called FTFY or Fix This For Me, For You.

01:06:32 Fix This For You.

01:06:33 It is a library to fix Mojibaki or text encoding errors.

01:06:41 So if you ever try to make sense of UTF-8 encoding text decoded as Latin 1 and then re-encoded as something else,

01:06:51 the Fix This For You library, FTFY library, will do it for you.

01:06:54 It automatically detects when an encoding was misapplied and fixes it for you,

01:07:00 as well as some other common noise in incoming text.

01:07:04 I love this for content management.

01:07:07 I love it for handling badly decoded webpages, anything like that.

01:07:12 Fix This For You has saved my backside a couple of times already.

01:07:16 That's fantastic.

01:07:17 All right, favorite editor?

01:07:19 If you're going to write some Python code, what do you open up?

01:07:21 If I'm on a terminal, Vim.

01:07:23 And generally on my desktop, it's Sublime Text 3.

01:07:26 Nice.

01:07:26 Yeah, I was just using Sublime Text earlier.

01:07:28 I like it a lot.

01:07:29 All right, how about a final call to action?

01:07:31 What should people do to get more involved with Stack Overflow?

01:07:34 Common and try and answer stuff.

01:07:36 There are always niche tags that need more people answering.

01:07:40 Things like Python may be overflown with people that know their things.

01:07:45 But if you have a specific expertise in programming, there usually is a tag for you.

01:07:51 And finding more answers to these questions are always helpful.

01:07:54 All right, excellent.

01:07:55 Well, thank you for all the work you've done on Stack Overflow around Python.

01:07:59 It's really amazing.

01:08:00 And thanks for being on the show.

01:08:01 Great to talk to you.

01:08:02 Cool.

01:08:02 Great.

01:08:03 Thanks.

01:08:03 Bye.

01:08:05 This has been another episode of Talk Python to Me.

01:08:08 The guest today has been Martin Peters.

01:08:11 This episode has been sponsored by Rollbar and GoCD.

01:08:14 Thank you both for supporting the show.

01:08:16 Rollbar takes the pain out of errors.

01:08:19 They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.

01:08:27 As Talk Python to Me listeners, track a ridiculous number of errors for free at rollbar.com slash Talk Python to Me.

01:08:33 GoCD is the on-premise, open-source, continuous delivery server.

01:08:38 Want to improve your deployment workflow but keep your code and builds in-house?

01:08:43 Check out GoCD at talkpython.fm/G-O-C-D and take control over your process.

01:08:49 Are you or a colleague trying to learn Python?

01:08:51 Have you tried books and videos that just left you bored by covering topics point by point?

01:08:56 Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course to experience a more engaging way to learn Python.

01:09:05 And if you're looking for something a little more advanced, try my Write Pythonic Code course at talkpython.fm/Pythonic.

01:09:12 You can find the links from this episode at talkpython.fm/episodes slash show slash 86.

01:09:19 Be sure to subscribe to the show.

01:09:21 Open your favorite podcatcher and search for Python.

01:09:23 We should be right at the top.

01:09:25 You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.

01:09:34 Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.

01:09:39 Corey just recently started selling his tracks on iTunes.

01:09:42 So I recommend you check it out at talkpython.fm/music.

01:09:46 You can browse his tracks he has for sale on iTunes and listen to the full-length version of the theme song.

01:09:51 This is your host, Michael Kennedy.

01:09:53 Thanks so much for listening.

01:09:54 I really appreciate it.

01:09:56 Smix, let's get out of here.

01:10:06 I'll see you next time.

01:10:18 Bye.

01:10:18 Bye.

01:10:19 Bye.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon