9 Aug
2002
9 Aug
'02
3:39 p.m.
If someone really wants 'abc'.replace('', '-') to return '-a-b-c-', please submit patches for both 8-bit and Unicode strings to SourceForge and assign to me. I looked into this and it's non-trivial: the implementation used for 8-bit strings goes into an infinite loop when the pattern is empty, and the Unicode implementation tacks '----' onto the end. Please supply doc and unittest patches too. At least re does the right thing already:
import re re.sub('', '-', 'abc') '-a-b-c-'
--Guido van Rossum (home page: http://www.python.org/~guido/)