[Python-Dev] Fwd: Problem withthe API for str.rpartition()
Barry Warsaw
barry at python.org
Tue Sep 5 22:55:44 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iQCVAwUBRP3kUHEjvBPtnXfVAQJd6wP+OBtRR22O0A+s/uHF3ACgWhrdZJdEnzEW
qimKEWmDCUuK7CFIUsJKteoNNSHjIBgZIMMdnsymgI7CPgPNuB6CUAp8KFFeYvMy
PVpMIqNFOFXGUVYf4VA7ED9S7QbbDzHJv32kUUZvbuTniYK9DVMi0O7GStsv1Kg6
insyP+W1EcU=
=4aar
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list