This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients SilentGhost, Stéphane Henriot, ericvw, georg.brandl, martin.panter, r.david.murray, serhiy.storchaka, vstinner
Date 2019-10-28.15:58:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572278339.52.0.223235128078.issue28029@roundup.psfhosted.org>
In-reply-to
Content
The current behavior is really surprising.

>>> "".replace("", "|")
'|'
>>> "".replace("", "|", -1)
'|'

vs

>>> "".replace("", "|", 0)
''
>>> "".replace("", "|", 1)
''
>>> "".replace("", "|", 1000)
''

I always expect "|".

---

This behavior makes sense to me:

>>> "abc".replace("", "|")
'|a|b|c|'
>>> "abc".replace("", "|", -1)
'|a|b|c|'
>>> "abc".replace("", "|", 0)
'abc'
>>> "abc".replace("", "|", 1)
'|abc'
>>> "abc".replace("", "|", 100)
'|a|b|c|'
History
Date User Action Args
2019-10-28 15:58:59vstinnersetrecipients: + vstinner, georg.brandl, ericvw, r.david.murray, SilentGhost, martin.panter, serhiy.storchaka, Stéphane Henriot
2019-10-28 15:58:59vstinnersetmessageid: <1572278339.52.0.223235128078.issue28029@roundup.psfhosted.org>
2019-10-28 15:58:59vstinnerlinkissue28029 messages
2019-10-28 15:58:59vstinnercreate