Re: [Python-Dev] replace on empty strings

2006-05-24 Thread Guido van Rossum
On 5/24/06, Greg Ewing <[EMAIL PROTECTED]> 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 emp

Re: [Python-Dev] replace on empty strings

2006-05-24 Thread Tim Peters
[/F] >> so, which one is correct ? >> >> Python 2.4.3 >> >>> "".replace("", "a") >> '' >> >>> u"".replace(u"", u"a") >> u'a' [Greg Ewing] > 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 in

Re: [Python-Dev] replace on empty strings

2006-05-24 Thread Greg Ewing
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

Re: [Python-Dev] replace on empty strings

2006-05-24 Thread Guido van Rossum
On 5/24/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > so, which one is correct ? > > Python 2.4.3 > >>> "".replace("", "a") > '' > >>> u"".replace(u"", u"a") > u'a' Since 'x'.replace('', 'a') and u'x'.replace('', u'a') return 'axa' and u'axa', respectively, I conclude that the unicode version i

[Python-Dev] replace on empty strings

2006-05-24 Thread Fredrik Lundh
so, which one is correct ? Python 2.4.3 >>> "".replace("", "a") '' >>> u"".replace(u"", u"a") u'a' ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/opti