[issue30352] The 'in' syntax should work with any object that implements __iter__

Steven D'Aprano report at bugs.python.org
Fri May 12 09:29:36 EDT 2017


Steven D'Aprano added the comment:

This is not a small change, and will need careful thought.

The problem is that in Python 3 (and in Python 2 for new-style classes), dunder methods are only called by the interpreter if they are defined on the class itself, not on the instance. That's an optimization, and it does mean that (for example) automatic delegation doesn't work with dunder methods.

But if we change this, we should change it for *all* dunder methods, not just __iter__. It would be a problem if we start "fixing" dunders piecemeal, one at a time. Either they should all work (like with classic classes) or none of them should.

So this is potentially a big change.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30352>
_______________________________________


More information about the Python-bugs-list mailing list