[Python-Dev] None as slice params to list.index() and tuple.index() (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Nov 6 20:16:44 CET 2011
- Previous message: [Python-Dev] None as slice params to list.index() and tuple.index()
- Next message: [Python-Dev] None as slice params to list.index() and tuple.index()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 6 Nov 2011 09:49:27 +0200 Petri Lehtinen <petri at digip.org> wrote:
list.index() and list.tuple() don't currently accept None as slice parameters, as reported in http://bugs.python.org/issue13340. For example:
>>> [1, 2, 3].index(2, None, None) Traceback (most recent call last): File "", line 1, in TypeError: slice indices must be integers or None or have an index method The error message of list.index() and tuple.index() (as a consequence of using PyEvalSliceIndex() for parsing arguments) indicates that None is a valid value. 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?
Either that or fix the error message. I can't find much benefit in accepting None, that said (nor in refusing it).
Regards
Antoine.
- Previous message: [Python-Dev] None as slice params to list.index() and tuple.index()
- Next message: [Python-Dev] None as slice params to list.index() and tuple.index()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]