[Python-Dev] partition() (was: Remove str.find in 3.0?)
raymond.hettinger at verizon.net
Tue Aug 30 03:26:35 CEST 2005
[Delaney, Timothy (Tim)]
> This is very useful behaviour IMO.
Thanks. It seems to be getting +1s all around.
> Have the precise return values of partition() been defined?
. . .
> IMO the most useful (and intuitive) behaviour is to return strings in
> all cases.
Yes, there is a precise spec and yes it always returns three strings.
Movitation and spec:
Pure python implementation, sample invocations, and tests:
> My major issue is with the names - partition() doesn't sound right to
FWIW, I am VERY happy with the name partition(). It has a long and
delightful history in conjunction with the quicksort algorithm where it
does something very similar to what we're doing here: partitioning data
into three groups (left,center,right) with a small center element
(called a pivot in the quicksort context and called a separator in our
string parsing context). This name has enjoyed great descriptive
success in communicating that the total data size is unchanged and that
the parts can be recombined to the whole. IOW, it is exactly the right
word. I won't part with it easily.
More information about the Python-Dev