[Python-Dev] replace on empty strings (original) (raw)
Guido van Rossum guido at python.org
Thu May 25 03:33:47 CEST 2006
- Previous message: [Python-Dev] replace on empty strings
- Next message: [Python-Dev] Socket regression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 5/24/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Fredrik Lundh wrote: > so, which one is correct ? > > Python 2.4.3 > >>> "".replace("", "a") > '' > >>> u"".replace(u"", u"a") > u'a'
Probably there shouldn't be any "correct" in this case, i.e. the result of replacing an empty string should be undefined (because any string contains infinitely many empty substrings).
No. That's what older versions of Python did, and it was changed to the current behavior, except someone screwed up the edge case for 8-bit strings.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] replace on empty strings
- Next message: [Python-Dev] Socket regression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]