Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
There are expected some relations between str methods. For example, s.replace(a, b, n) == s.replace(a, b) if n >= s.count(a) len(s.replace(a, b, n)) == len(s) + (len(b)-len(a)) * n if 0 <= n <= s.count(a) len(s.replace(a, b, n)) == len(s) + (len(b)-len(a)) * s.count(a) if n >= s.count(a) Inconsistency between "".replace("", s, n) and "".replace("", s) is just a bug, and it should be fixed in the most consistent way. There are precedences, the behavior of replace() already was changed 3 times in the past. I think that chances to break some code are tiny, we just fix inconsistency why can puzzle users. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue28029> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com