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

2017-05-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 on this proposal. We haven't really seen a need for this in practice. And such as change would be likely create unforeseen consequences to existing code. The proposal is at odds with the existing design. Python internals work by checking for whethe

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

2017-05-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: A further thought... looking at your example code, I believe that part of the __getattr__ is redundant. def __getattr__(self, item): try: return self.__getattribute__(item) except AttributeError: return self.f.__geta

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

2017-05-12 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +rhettinger, xiang.zhang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

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

2017-05-12 Thread Steven D'Aprano
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 optim

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

2017-05-12 Thread Edouard KLEIN
New submission from Edouard KLEIN: In this StackOverflow question: http://stackoverflow.com/questions/43935187/how-come-an-object-that-implements-iter-is-not-recognized-as-iterable/43935360#43935360 the question of why an object that implements __iter__ through __getattr__ does not work with t