Hacker News new | ask | show | jobs
by jbay808 2413 days ago
I don't know about you, but when I search for "python string replace" I'd expect the first result to be the Python 3 documentation for 'string'.

Instead, I get (in order):

1. GeeksforGeeks

2. Tutorialspoint

3. W3Schools

4. Programiz

5. Stack overflow

6. And then, finally, the official documentation... For python 2.7.

How does this happen? Are these sites just paying Google a bunch for the rankings?

4 comments

Honestly, this is because the organization of the Python 3 docs is terrible.

The documentation for str.replace is located halfway down an enormous page that describes every single built-in type in the language [1].

And then, once you manage to find the entry for str.replace, what does it tell you?

Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.

That's it. No examples, no link to re.sub or other functions you might want to use for replacement. Stack Overflow or even W3Schools (gasp!) is much better results for this.

[1] https://docs.python.org/3/library/stdtypes.html

Incidentally, if this is the level of information you are looking for, you can get the same thing by typing help(str.replace) in the Python interpreter.
I wouldn't expect the official documentation for anything to fare well with web search algorithms. This is probably a place where I'd support manual intervention, to boost docs/manuals/man pages/etc.
I for one have never cared for the Python Doc Site and layout. Too much info for a "quick" lookup. I only need 1 line of code to show me how to replace strings in p3
Maybe because more people who types those queries find the first result from GeeksforGeeks page more useful ? People searching for those are more likely beginner programmers. Being an old unix geek, I personally do like the official documentation better but it's true the official documentation is a lot more obtuse for beginners, whereas that first result looks a lot more friendly with examples, etc.