[issue31956] Add start and stop parameters to the array.index()

Anders Lorentsen report at bugs.python.org
Sun Sep 15 19:33:40 EDT 2019


Anders Lorentsen <phaqui at gmail.com> added the comment:

I have actually managed to lost my local branch of this fix, though I assume I can just start another one, manually copy over the changes, somehow mark this current PR as cancelled, aborted, or in my option the best: "replaced/superseeded by: [new PR]". In any case, there were discussions that seem to be unresolved, allow me to summarize:

* Document that index() raises ValueError when *value* is not found?
> vstinner: We don't do this, remove this addition.
> serhiy: Other index() methods does this.
---> My patch current does this. Who has final saying here?

* 'start' and 'stop' arguments are not keyword arguments, and also not shown in the signature as '.. start=0 ..' for this very reason (it may make them look as keyword arguments). Also, this lines up with list.index() for consistency. Wishes about changing this for all index()-methods has been expressed, but it seems to be consensus on doing this in unison for all index()-methods at once, in a bigger change... So, what is currently in the PR is good enough for now, or?

* Wording in documentation: Clarify that "the returned index is still relative to the start of the array, not the searched sub sequence" or not?

* Comment in the code about checking the length of the array on each iteration? There were comments about it being "confusing" - and while I agree, the other index()-code for lists, does not comment on this. Again I followed the path of most consistency, but I did receive comments about this. Yes to descriptive comments, or not?

----

Generally speaking: In the end, all I really did was mimic how list.index() is both written and documented, and that's when discussions about issues related to that started occurring, and so I now remember that I halted my PR, waiting for these issues to be resolved.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31956>
_______________________________________


More information about the Python-bugs-list mailing list