[Python-Dev] Fwd: Problem withthe API for str.rpartition()
jimjjewett at gmail.com
Tue Sep 5 20:02:31 CEST 2006
On 9/5/06, Fred L. Drake, Jr. <fdrake at acm.org> wrote:
> S.partition(sep) -> (head, sep, rest)
> S.rpartition(sep) -> (tail, sep, rest)
> Here, "rest" is always used for "what remains"; head/tail are somewhat more
> clear here I think.
Then shouldn't rpartition be S.rpartition(sep) -> (rest, sep, tail)
Another possibility is data (for head/tail) and unparsed (for rest).
S.partition(sep) -> (data, sep, unparsed)
S.rpartition(sep) -> (unparsed, sep, data)
I'm not sure which is worse --
(1) distinguishing between tail and rest
(2) using (overly generic) jargon like unparsed and data.
Whatever the final decision, it would probably be best to add an
example to the docstring. "a.b.c".rpartition(".") -> ("a.b", ".",
More information about the Python-Dev