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

Jim Jewett jimjjewett at gmail.com
Tue Sep 5 18:08:19 CEST 2006


Reversing the order of the return tuple will break the alignment with
split/rsplit.

Why not just change which of the three strings holds the remainder in
the not-found case?

In rc1,

    "d".rpartition(".") --> ('d', '', '')

If that changes to

    "d".rpartition(".") --> ('', '', 'd')

then
(1)  the loop will terminate
(2)  rpartition will be more parallel to partition (and split),
(3)  people who used rpartition without looping to termination (and
therefore didn't catch the problem) will still be able to use their
existing working code.
(4)  the existing docstring would remain correct, though it could
still be improved.  (It says "returns S and two empty strings", but
doesn't specify the order.)

-jJ


More information about the Python-Dev mailing list