75

For the umpteenth time someone asked the question "what does 'str object is not callable' mean?" with the tag [python]. This is a very common error for newbies, so it just gets asked over and over and over, each time in a slightly different context. A little spot checking shows that nearly every answer seems to get one or two upvotes, and the answers always directly address the specific code in the question rather than giving a more generic faq-like answer.

The best answer, IMHO, is to explain the meaning behind the error message ("what is 'str'" in this context, what is "callable", and "why isn't it callable", etc). I'd like to find or write a definitive answer but am struggling to find a good candidate. What to do?

Should I ask it once more myself, write what I think is a good general purpose answer, and then hunt down all the similar questions and mark them as dupes? Or, pick an existing answer? If the latter, do I pick the oldest? The one with the most up-votes on the question? The one with the most upvotes on the answer? If I find an existing question and answer, is it kosher to make substantial edits to make the answer more generic?

17
  • 34
    You seem to be describing a canonical question, which is indeed an approved practice here. Pick the best existing Q&A regardless of date, possibly editing it mildly, or write your own if there's no good one. python has a good culture for this (as best I can tell as an outsider); check sopython.com/canon or the chat room first. Commented Mar 28, 2016 at 23:21
  • 7
    You are kinda doing what these questioners are doing. Just google "python object is not callable" and pick the top hit, doesn't take more than that. Commented Mar 28, 2016 at 23:23
  • 5
    @HansPassant: perhaps. Though, if I was faced with "str is not callable" and I was told it was a dupe of "what is a callable", which was the first hit on that search for me. I don't think that would be very helpful. Knowing what a callable is would be part of the answer, but not the whole answer. Commented Mar 29, 2016 at 0:01
  • 6
    What about this? (60 seconds of searching)
    – user4639281
    Commented Mar 29, 2016 at 3:34
  • @TinyGiant: I would say your search fu is stronger than mine. That's a pretty good candidate for a canonical answer. Thanks! I'll add that to my list of duplicates to use. Commented Mar 29, 2016 at 6:39
  • 2
    Related: Would it be appropriate to create a better duplicate?
    – Sayse
    Commented Mar 29, 2016 at 8:13
  • 4
    Go look up questions about NullReferenceExceptions. They're all dupehammered with a canonical. Find your canonical, wield your dupehammer.
    – user1228
    Commented Mar 29, 2016 at 15:12
  • 1
    Is there a list of canonical questions somewhere, or am I supposed to guess which of the thousands of questions has been declared canonical? I'm on the [batch-file] tag almost exclusively, and if I had a nickel for every time somebody asked a question about why a variable wasn't updating inside of a loop, I could retire. Commented Mar 30, 2016 at 5:53
  • How do you know 100 Same like questions found in SO ?
    – M D
    Commented Mar 30, 2016 at 13:25
  • @SomethingDark - Some times the language tag has a "FAQ" section, example
    – Sayse
    Commented Mar 30, 2016 at 13:59
  • @SomethingDark Let me find Canonical Questions But this never got of the ground
    – Jan Doggen
    Commented Mar 30, 2016 at 14:00
  • @MD: "How do you know 100 Same like questions found in SO": I'm not sure who you are addressing that comment to. If me, I simply did a search on SO for "[python] str object not callable is:question". Nearly 600 results. Commented Mar 30, 2016 at 14:14
  • Out of curiosity, what makes a question "basic"? What concrete attributes do all "basic" questions share?
    – Travis J
    Commented Mar 31, 2016 at 18:31
  • @TravisJ: in this case, "basic" referred to the fact that there are hundreds of ways to write code that generate a "str object is not callable" error. All of the ways ultimately boil down to a basic problem of using an object in a wrong way. You could be using classes or not, you could be writing a web app, a command line tool, a GUI, etc. but it's all the same fundamental problem, usually brought about by making invalid assumptions. Commented Mar 31, 2016 at 18:47
  • @BryanOakley - So if there are hundreds of paths that end in the same result, then doesn't it make sense that there are coverage for these various paths in the form of questions which are for the most part duplicates? Perhaps it would make more sense to address how to merge sets of paths that lead to this end result in order to reduce the hundreds to possible dozens.
    – Travis J
    Commented Mar 31, 2016 at 18:54

4 Answers 4

64

Yes, it's a good idea to either pick up an existing question or ask and answer a reference question of your own, as it will be exactly within the declared site guidelines.

No, it won't change anything regarding the number of basic questions asked and answered, as it will be against the actual modus operandi of Stack Overflow.

Although you may start using your own reference question for closures, other participants will hardly notice it, and will continue answering repeated basic questions instead of closing them. And even get on you for "not helping people".

You have to realize that Stack Overflow, with all its gamification stuff, is essentially after "getting one or two upvotes for the answers that directly address the specific code in the question".

Edit.

Some people accuse me for being too pessimistic.
Some other people telling me tales how great Stack Overflow is and how it's successful in cleaning bad stuff. The problem is, I grew up in the Soviet Union, and for the rest of my life I am immune to this kind of tales, when people are trying to sell me things opposite to what I can see with my own eyes.

And my eyes are telling me that things are quite different. Instead of "being removed at a reasonable pace", bad questions rather get revived.

A fresh example. There is an exemplary offtopic question, of the usual "I wrote a code that doesn't work, fix it for me" kind.

You will never get enough votes to close it as offtopic, partly due to rep-whores, for which such a question is the best forage, partly to clueless reviewers, who is able to comprehend grammar mistakes only.

Yet, beside being off topic, this question is a duplicate as well. And here comes another dilemma. The closure reason could be either "a fish", or a "lesson how to fish". One could argue which is better, but at least both are legitimate. Especially taking into account the declared goals of Stack Overflow: to let many people learn from the single answer. From this point of view, the answer with "a fish" will help the OP only, while the answer with a lesson will help anyone.

Personally I prefer the latter one. So it was used.

So far so good. The answer for the OP is given in the very first comment; off topic question is closed; for someone else having a problem adding stuff in the database the answer how to get an error message is given. Happy end?

Not quite. After time being, out of a clear sky here comes a mod. And opens this post back.

This is a real Stack Overflow.

So don't sell me tales how well it is in cleaning a bad stuff.

27
  • 22
    Is it ironic that I upvoted this answer because of your last sentence?
    – alexw
    Commented Mar 29, 2016 at 17:34
  • 3
    @CodeCaster these votes still contribute to the quality ban algorithm, so keep casting. Commented Mar 30, 2016 at 11:33
  • 6
    @Jan the problem is not the single user who asks a "debug this for me" question, the problem is the thousands of other users on the site who are willing to debug their code for them and write a one-off answer that will never help anybody else.
    – CodeCaster
    Commented Mar 30, 2016 at 11:34
  • 1
    @CodeCaster pretty much yes, with one little correction: we cannot pile up our votes. You will never get 5 votes for an offtopic question - so, in time your vote will just crumble in vain. Commented Mar 30, 2016 at 11:34
  • 1
    @CodeCaster Do you mean one question per user and day, or one per day among all users?
    – Oriol
    Commented Mar 30, 2016 at 11:40
  • 6
    @Oriol it doesn't matter really. As long as the talk is about Stack Overflow, nobody will change anything. Ever. Commented Mar 30, 2016 at 11:43
  • 2
    @YourCommonSense I am prone to bouts of pessimism myself, but this seems like a pretty useless attitude.
    – jpmc26
    Commented Mar 30, 2016 at 13:13
  • 2
    One little thing here though, there is nothing that states that an answerer must contribute an answer that will help other people down the road. Likewise there is nothing that states that an answerer cannot answer an open question that is not likely to help other people down the road. There is nothing that states that anyone must cast close votes on a question instead of posting an answer. We may all not like users that get their reputation through answering in this manner, but they aren't actually doing anything wrong. The only thing we can do is close vote bad questions quickly.
    – user4639281
    Commented Mar 30, 2016 at 15:30
  • 3
    @Tiny people who answer bad questions are doing something wrong. They're sending out a signal that any question will get answered, regardless of its quality.
    – CodeCaster
    Commented Mar 30, 2016 at 21:03
  • 4
    "but they are also being removed at a reasonable pace" - it's a lie. Commented Mar 31, 2016 at 18:47
  • 2
    So you would call me a liar rather than examine the points I make? That is a baseless accusation, as evidenced by your reluctance to cite data both in your attack and in regards to a lack of response to my points.
    – Travis J
    Commented Mar 31, 2016 at 18:57
  • 2
    @CodeCaster "People who answer bad questions are doing something wrong" - then why does SO reward them for it? Commented Mar 31, 2016 at 19:45
  • 3
    @immibis I don't see what you're trying to get at. People should not answer questions that should be closed, period. The fact that they do, and do get upvoted at that, is in my opinion a problem, because it sends out a signal: no matter how bad your question is, you will get an answer. Various suggestions to prevent that have been coined, none of which are viable. So I don't know what we should do.
    – CodeCaster
    Commented Mar 31, 2016 at 20:29
  • 2
    "You will never get 5 votes for an offtopic question" Nonsense. Questions get closed all the time. There's just too much crap posted to close all of it. I'd love to see you write an answer where you don't draw shortsighted conclusions from your observations, for once.
    – Cerbrus
    Commented Apr 1, 2016 at 6:38
  • 2
    @CodeCaster: Now don't go stealin' my format ;-) What I was saying is that YCS was implying nothing ever gets closed. That's as far from the truth as it gets.
    – Cerbrus
    Commented Apr 1, 2016 at 11:22
26

To start with, yes, we should be closing these down. They're not useful questions. StackOverflow's goal is to be an information repository for people to learn from, not a free code debugging service. Questions at this level of specificity and that lack research are not going to be useful to other people. It is a completely appropriate action to close these as duplicates of questions that have answers explaining the real meaning of the error and how to go about fixing it. So as stated in the comments, find an appropriate dupe (or create a canonical) and start closing.

You have a gold badge in Python as well, meaning you can unilaterally close these. You might be hesitant to use this ability on such a large number of questions, but I would encourage you to go ahead with it. The close hammer has been called a "resounding success", and this kind of trash clean up is exactly what it was intended to aid with. If you need help, coordinate with other users (here, chat).

I do think that posting on meta asking about issues like this is a good idea. Given the sheer number of affected questions, this isn't something you want to start doing without making sure you're on the right track. Maybe we need a catchy phrase to describe these kinds of efforts, like tag removal has "burnination."

As for going forward, the efforts to clean up the existing mess may not stop the flood of incoming questions of this variety, but if people do bother to Google, they may find that a huge pile of results linking them to a single question to be a sign they need to read that question. It certainly can't hurt, and it may help a little going forward. It also establishes example behavior here for the users who are answering these questions; perhaps some of them might start flagging to close instead of answering. Bottom line: it won't end these questions, but it's a nice start in the right direction, and ignoring the problem will only allow it to get worse.

5
  • "Hammernination"?
    – user4639281
    Commented Mar 30, 2016 at 3:12
  • 2
    @TinyGiant Maybe just "Hammer Time"? =)
    – jpmc26
    Commented Mar 30, 2016 at 3:14
  • Too confusing, how many people would think it was a dedication to mc hammer?
    – user4639281
    Commented Mar 30, 2016 at 3:18
  • 2
    "It's CLOBBERIN' time!" - The Thing Commented Mar 30, 2016 at 12:07
  • This STLL leaves the people that ask and answer these question with their rep reward! The question needs deleting as well as closing as a duplicate so as remove the reward. Commented Mar 31, 2016 at 16:49
6

As a stopgap measure, I added the question suggested by Tiny Giant in a comment to the SOPython Common Questions database. I also brought this question to the attention of the python chat room.

The entry I added is still a draft (100 rep required): http://sopython.com/canon/98/typeerror-x-object-is-not-callable/

You are of course still free to propose a better canonical question; perhaps then similarly bring it up in the chat room first, and coordinate with the friendly pythonistas there.

I'm documenting this as an answer mainly because the Python community on Stack Overflow has an exceptionally active chat room and dedicated wiki for this sort of thing; you should at least know about them if you participate in this tag.

6

Yes, "str object is not callable" is a very common error. Sometimes the asker has masked the str() function by calling their string str. Sometimes they're just adding parentheses after a string for no apparent reason. A quick Google of site:stackoverflow.com python str not callable (I do this a lot; Google sometimes asks me if I'm sure I'm not a robot) seems to focus mostly on those two reasons. People who ask this question probably could have done a bit more research. However, they do not. Why, you ask? Fortunately, I have the following infographic for you:

useful infographic

Most useful programming knowledge is on SO. That's why SO is so popular: if you're wondering something about how to program, you can probably find it here. It's great. Just the other day I found a delightful little snippet about how to add a tooltip to a widget in Tkinter with nothing but an import of an included library and a simple tip = Tip(widget, text) (oddly, a Tkinter question with no answer from Bryan Tcl/Tk Oakley :P).

But how about that other circle, the one I labeled as "crap" and colored an ominous brown? That is the bulk of Stack Overflow: the incredible mountain of Big Data delivered unto us by the 99% of programmers who don't know how to research any more than they know how to program. Sometimes they are not even programmers - they are professionals from other fields who stumbled upon an article claiming that "R is an excellent language for data analysis" or "Python is making a big splash in bioinformatics" and then dove into the deep end (either of their own volition or after their manager made it a priority zero key ask). Professionals or not, they still don't understand that you have to learn a language before using it, whether it's a human language or a programming language. It seems so simple at first: learn the magic words, write them, and it works.

Except when it doesn't. Then, instead of figuring "I better go back and learn this before using it," it seems much faster to ask someone to take a glance at the magic words. And whom shall they ask? I'll give you a hint: us. This is the crap, and it is flowing inexorably into SO via osmosis and laziness. We cannot stop it. All we can do is bail as fast as we can, tossing these questions into the duplicate pile, closing as too broad, closing as "off-topic for SO because this is your homework, not mine, and I don't care that you let it sit on your desk for a week and it's due tomorrow, I'm still not doing it for you," and answering for 2-3 points.

Note how the last option - answering questions - is the only way to get rep (past the couple thousand for approved edits), and further note how most of everything is crap. Logically, then, the most reliable way to boost your reputation on SO as a programming wizard is to answer crap and duplicates (I occasionally dupehammer questions after they've already been answered, and the person who answered the question I just closed is the same one who answered the canonical duplicate), because if you wait for gems you will be old and gray before you get anywhere on this site. This hasn't always been the case - after all, the very first person to post stupid question X wasn't asking such a stupid question, at least in terms of SO. Maybe the information they needed was easily available elsewhere (e.g., the change from print statement in Python 2 to print() function in Python 3 was available in the release notes, along with many less-visible changes), but it wasn't yet easily available on SO per se.

Direct answers to your specific questions:

  1. What to do? - Find a duplicate if possible. If none exists, answer the question to broaden the duplicate pool.
  2. Should I write my own canonical QA and crush all other similar questions in my path? - Sure, as long as your canonical effort is appropriate and relevant to each question you hammer.
  3. Which duplicate should I pick? - The one that'll cause the least argument. Generally I look for highly-upvoted answers, with the "correct" one for the topic at hand being the top answer on that question (answers past the first do not exist). Be prepared for nonsense like "but the string that question is trying to call is named example, while the string this question is trying to call is named test! It's not a duplicate at all! Who made you a moderator on this forum!?" Instead of getting a headache, close the tab and move on with your life.
  4. Should I make edits? - If you're making it better, sure. If not, then no. It doesn't matter in the slightest that your motivation is frustration at the lack of a canonical question. If improving it for your purposes makes it better, go ahead. I wouldn't edit a "put () after a string for no reason" question to also have something about str = 'hello', but if you want to add something about "you may also run into this error if you mask str()" to an answer, that seems fine to me.

TL;DR: As the VP of R&D at my old company would say in his heavy Middle-Eastern accent, "it is crap." But it's okay.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .