Ionel Cristian Mărieș added the comment:

Turns out I've replied through email, and code got mangled. This is the correct 
version:

class GenericProxy:
    def __init__(self, proxied):
        self.proxied = proxied

    @property
    def __iter__(self):
        if not hasattr(self.proxied, '__iter__'):
            raise AttributeError
        else:
            return lambda: self
    @property
    def __next__(self):
        if not hasattr(self.proxied, '__next__'):
            raise AttributeError
        else:
            return lambda: next(self.proxied)

Note the lambdas.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23990>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to