[Python-Dev] Re: string.find() again (was Re: timsort for jython)

Guido van Rossum guido@python.org
Fri, 09 Aug 2002 11:39:30 -0400


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/)