On Fri, Apr 20, 2001 at 04:48:06PM -0500, Guido van Rossum wrote:
[GVW]
Turns out that "abbc".replace("b", "x", -1) is "axxc" (i.e. negative arguments are ignored). I would have expected this to raise a ValueError, if anything. Is there a reason for this behavior? Is it worth making replace, split, etc. interpret negative indices in the same way as indexing does?
Dubious hypergeneralization. The thing is that this parameter, called maxsplit, is not really an index -- it's a count.
Wouldn't it be nice if we could force particular arguments to be used as
keyword arguments only ? :) I remember this coming up a few times on
python-list, but I never quite understood why this isn't done. Syntax
doesn't seem too much of a problem ('def split(s, sep, **, maxsplit=0)'
comes to mind, and a new marker for PyArg_ParseTuple, like "**") and now
that we have warnings and __future__, we could phase it in even for oft-used
things such as string.split().
Even if it's deemed dubious hypergeneralization (look ma, no macro ;) it's
worth writing a PEP about, right ?
--
Thomas Wouters