Message279414
Interestingly, initially string.replace() was implemented in terms of split/join. string.replace(s, '', s2, n) returned s for any s, s2 and n.
After making replace() a method of str, in aca7b5eaf5e8 (1999-10-12), it became raising ValueError for empty pattern string.
Since 762dd09edb83 (issue599128, 2002-08-23) it supports zero-length pattern string. str.replace('', s1, s2, n) returned '' for any s1, s2 and n.
New implementation added in 41809406a35e (2006-05-25) made str.replace('', '', 'x', -1) returning 'x' while str.replace('', '', 'x', 1) still returns ''.
As you can see, the behavior of replacing with empty pattern is not stable. It was changed several times. Maybe it is a time for new change. |
|
Date |
User |
Action |
Args |
2016-10-25 15:24:49 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, georg.brandl, vstinner, ericvw, r.david.murray, SilentGhost, martin.panter, Stéphane Henriot |
2016-10-25 15:24:49 | serhiy.storchaka | set | messageid: <1477409089.34.0.118379259945.issue28029@psf.upfronthosting.co.za> |
2016-10-25 15:24:49 | serhiy.storchaka | link | issue28029 messages |
2016-10-25 15:24:49 | serhiy.storchaka | create | |
|