New submission from Devin Jeanpierre: >>> class AppendOnUnequal(object): ... def __init__(self, append_to): ... self.append_to = append_to ... def __eq__(self, other): ... if self is other: ... return True ... self.append_to.append(self) ... return False ... >>> L = [1]; AppendOnUnequal(L) in L True >>> L = [1]; L.count(AppendOnUnequal(L)) 1 >>> L = [1]; L.remove(AppendOnUnequal(L)) >>> L = [1]; L.index(AppendOnUnequal(L)) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: <__main__.AppendOnUnequal object at 0x7f2562d071d0> is not in list
.index() is the only odd one out here. Looks like a bug to me. ---------- components: Interpreter Core messages: 233721 nosy: Devin Jeanpierre priority: normal severity: normal status: open title: list.index and rest of list methods disagree if a value is in the list if it's mutated during the call type: behavior versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23204> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com