Hacker News new | ask | show | jobs
by jonas21 2412 days ago
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

1 comments

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.