[Python-Dev] Fwd: Problem withthe API for str.rpartition()

Phillip J. Eby pje at telecommunity.com
Tue Sep 5 23:07:17 CEST 2006


At 04:55 PM 9/5/2006 -0400, Barry Warsaw wrote:
>On Sep 5, 2006, at 4:43 PM, Jim Jewett wrote:
>
> > I think I finally figured out where Raymond is coming from.
> >
> > For Raymond, "head" is where he started processing -- for rpartition,
> > this is the .endswith part.
> >
> > For me, "head" is the start of the data structure -- always the
> > .startswith part.
> >
> > We won't resolve that with anything suggesting a sequential order; we
> > need something that makes it clear which part is the large leftover.
>
>See, for me, it's all about the results of the operation, not how the
>results are (supposedly) used.  The way I think about it is that I've
>got some string and I'm looking for some split point within that
>string.  That split point is clearly the "middle" (but "sep" works
>too) and everything to the right of that split point gets returned in
>"right" while everything to the left gets returned in "left".

+1 for left/sep/right for both operations.  It's easier to remember a 
visual correlation (left,sep,right) than it is to try and think about an 
abstraction in which the order of results has something to do with what 
direction I found the separator in.

If I'm repeating from right to left, then of course the "left" is the part 
I'll want to repeat on.



More information about the Python-Dev mailing list