Kaleb Barrett <dev.ktbarr...@gmail.com> added the comment:
And so it is... There is also a PR open with a solution from 2017. https://github.com/python/cpython/pull/4378/files. Can this get reviewed? The rationalizations against solving this bug stated in the original issue are weak, range.index *is* useful. I use range objects to describe alternate indexing schemes for an array type (to model HDL datatypes that allow arbitrary indexing schemes). range.index is used to translate user supplied indexes into 0-based indexes to index into a parallel list with the array values. https://github.com/cocotb/cocotb/pull/2510/files#diff-62a4545e5bbb9291f2bdb820609b2d68c69cbafe64faea83beb380d01c02fb5aR315-R319 Additionally, this causes issues with mypy. If you subclass Sequence, mypy will complain if you don't have the optional start and stop arguments in the index method. I would need to feed them into a range object in my implementation. I guess in my case I'm expected to just reject them? This breaks substitutability in my class. It also breaks substitutability with list, tuples, every built-in Sequence type as well. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43836> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com