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

Barry Warsaw barry at python.org
Tue Sep 5 22:55:44 CEST 2006

Hash: SHA1

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".

I'm less concerned with repeated splits because I probably have as  
many existing cases where I'm looking for the first split point as  
where I'm looking repeatedly for split points (think RFC 2822 header  
splitting -- partition will be awesome for this).

The bias with these terms is clearly the English left-to-right  
order.  Actually, that brings up an interesting question: what would  
happen if you called rpartition on a unicode string representing  
Hebrew, Arabic, or other RTL language?  Do partition and rpartition  
suddenly switch directions?

If not, then I think left-sep-right are fine.  If so, then yeah, we  
probably need something else.

- -Barry

Version: GnuPG v1.4.5 (Darwin)


More information about the Python-Dev mailing list