[Python-Dev] None as slice params to list.index() and tuple.index()

Raymond Hettinger raymond.hettinger at gmail.com
Sun Nov 6 20:56:41 CET 2011


On Nov 6, 2011, at 12:49 AM, Petri Lehtinen wrote:

> Currently, find(), rfind(), index(), rindex(), count(), startswith()
> and endswith() of str, bytes and bytearray accept None. Should
> list.index() and tuple.index() accept it, too?

The string methods accept None as a historical artifact
of being in string.py where optional arguments defaulted to None.
That doesn't imply that you should change every other API that
accepts a start argument.

The list.index() API is ancient and stable.  There has been little or
no demonstrated need for its start argument to be None.

Also, the list API does not exist in isolation.  It shows up in
strings, the sequence ABC, and every API that aspires to
be list-like. 

Overall, I'm -1 on this change and find it to be gratuitous.
We have *way* to many micro API changes of dubious benefit.

Also, the change should not have been applied to Py2.7 and Py3.2.
We don't backport API changes.   That would just make Jython
and IronPython become non-compliant in mid-stream.


Raymond


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20111106/6c87d74a/attachment.html>


More information about the Python-Dev mailing list