I think you're getting to implementation details here. Whether a new string is returned or a reference to the old one is an optimization decision. I don't think it's worth legislating this behavior one way or another (especially since it's mostly a theoretical issue).
--Guido On 5/26/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > On 5/26/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: > > [...] > >> And what happens if the separator is an instance of a subclass? > >> > >> class s2(str): > >> def __repr__(self): > >> return "s2(%r)" % str(self) > >> > >> print "foobar".partition(s2("o")) > >> > >> Currently this prints: > >> ('f', s2('o'), 'obar') > >> Should this be > >> ('f', 'o', 'obar') > >> or not? > >> > >> And what about: > >> print s2("foobar").partition("x") > >> Currently this prints > >> (s2('foobar'), '', '') > > > > These are both fine with me. > > split() doesn't behave that way: > > >>> s2("foobar").split("x") > ['foo'] > > Servus, > Walter > > > > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com