[Python-Dev] partition() variants
Guido van Rossum
guido at python.org
Fri May 26 18:58:43 CEST 2006
On 5/26/06, Walter Dörwald <walter at livinglogic.de> wrote:
> A.M. Kuchling wrote:
>
> > I didn't find an answer in the str.partition() thread in the archives
> > (it's enormous, so easy to miss the right message), so I have two
> > questions:
> >
> > 1) Is str.rpartition() still wanted?
Can't remember. Raymond?
> > 2) What about adding partition() to the re module?
No.
> 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.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list