
March 25, 2020
10:54 p.m.
On Tue, Mar 24, 2020 at 07:14:16PM +0100, Victor Stinner wrote:
I would prefer to raise ValueError("empty separator") to avoid any risk of confusion. I'm not sure that str.cutprefix("") or str.cutsuffix("") does make any sense.
They make as much sense as any other null-operation, such as subtracting 0 or deleting empty slices from lists. Every string s is unchanged if you prepend or concatenate the empty string: assert s == ''+s == s+'' so removing the empty string should obey the same invariant: assert s == s.removeprefix('') == s.removesuffix('') -- Steven