"Trivial" questions are not only answerable but vital
Are there questions that are too trivial to answer [on Stack Overflow]?
Possibly; but certainly none of your examples qualify. With the benefit of hindsight, simple questions like this have proven to be a massive boon for learners and educators alike.
In fact, here are several questions related to those examples that I've either helped to improve, or have found useful for closing duplicate questions (or both):
How slicing in Python works
How do I get the number of elements in a list (length of a list) in Python?
How do I get ("return") a result (output) from a function? How can I use the result later?
What is the purpose of the return statement? How is it different from printing?
Why is "None" printed after my function's output?
What is the purpose of the `self` parameter? Why is it needed?
"TypeError: method() takes 1 positional argument but 2 were given" but I only passed one
Why do I get "TypeError: Missing 1 required positional argument: 'self'"?
__init__() missing 1 required positional argument
All fundamental topics that every Python programmer should understand after "working through the basics". All things one would expect a decent "learn to program in Python" book to go over. All well received with high view counts.
But I'd like to go into more depth on a specific example.
Consider the popularity of a former canonical, IndentationError: unindent does not match any outer indentation level, although the indentation looks correct . It has attracted millions of views and far too many answers. A lot of the top answers really belong on How to fix Python indentation , or one of the more specific sub-questions, instead. Then there are answers describing other causes of the same error (the OP example is about mixed spaces and tabs, but it can happen other ways).
And that's just one variant of IndentationError
- others had separate canonicals, sort of, if curators could find them. So you got other highly-upvoted questions like What should I do with "Unexpected indent" in Python? and Why am I getting "IndentationError: expected an indented block"? . In 3.x, the rules got a bit stricter, resulting in the addition of "inconsistent use of tabs and spaces in indentation" - notice how the answers end up rehashing all the same advice about how to type the code, rather than focusing on what the code needs to contain.
It got bad enough that in 2017 Christian Dean created an artificial, self-answered canonical to round up the questions that are really all the same question answered in the same way, motivated by the same conceptual issue explained and fixed in the same way. And this faced heavy resistance at first; but thanks to the combined efforts of several regulars, it's now good enough that I can't see any reason to direct others to the previously mentioned questions instead (except the "how to fix" question, because that really is an orthogonal topic). There are some less common issues with IndentationError
that are better dealt with separately (in particular How can I write an empty indented block (and avoid an IndentationError) in Python? and Why do I get an IndentationError from a properly indented function (following a "try" with no "except")? - the latter is logically speaking not an indentation problem at all, but the result of older versions of Python using a parser with poorer error recovery); but overall if you get IndentationError
, that's what you're asking about.
As such, throughout last December or so I put in an extraordinary effort to clean up old dupes, and this canonical is now one of the most "frequent" in the Python tag, with over a thousand links. And that was mostly just from me cleaning up "tumbleweed" questions that had gone completely ignored. I only searched for questions with IndentationError
in the title, by the way; there could potentially be thousands more dupes (although of course a search like that will have many false positives).
The thing about all of that is that these problems are all the same conceptual issue, which is exclusive to beginners. Python programmers with any meaningful experience have been there and done that. They know what the rules are and what the code should look like; they write the code with a consistent style; they know how to configure their editors to facilitate a consistent style and also avoid stray tabs; they know how to check the code for stray tabs (or spaces, for those few curmudgeons who refuse to switch to space-based indents - I may have been one, in the 2000s); and they can instinctively respond to any IndentationError
with a troubleshooting checklist.
It's not as if there's a lack of explanation elsewhere, either. The indentation rules are comprehensively explained on a technical level in the documentation, the tutorial mentions code indentation in several places (1 2 3 and other mentions that are not as useful) and the Windows FAQ even advises about how to make MSVC not use tabs. Putting python indentation
into a search engine turns up all sorts of third parties who are champing at the bit to explain the concept, and that's hardly a new phenomenon. In short, anyone not knowing the fundamentals could have researched them just fine even in 2008 - if they knew what to look for.
But the thing is, beginners do not know what to look for, almost by definition. They have unknown unknowns. Copying and pasting an error message into a search engine is a good first step; but as already discussed, error messages do not map one-to-one with logical causes.
I hope the point is clear by now. That's just one topic, every "not a beginner" should be expected to understand it quite well already - and the interest is massive.
The site has clearly suffered from a reluctance to include such questions. People will ask whether you like it or not, and referring them to a high-quality duplicate is vastly better than trying to find another reason to close the question, which in turn is infinitely better than just downvoting it and giving the FGITW addicts free rein to rephrase the same explanation for the N+1th time. But there are so many cases now where the question is "obviously" a duplicate about something that could easily clearly be explained, but trying to find a canonical is an outright nightmare. I personally have accumulated almost two thousand questions in my Saves list, dominantly in an effort to improve the canonical-search process for myself - and this is more or less only considering the Python tag.
If you care about building a high-quality, searchable reference library, then you must admit questions that beginners need answered. (This is not the same as "questions that beginners asked, phrased the way beginners phrase them".) In every field, beginners will always greatly outnumber experts, and a proper understanding of fundamentals is crucial.