This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ionelmc
Recipients Claudiu.Popa, belopolsky, christian.heimes, ethan.furman, ionelmc, jedwards, llllllllll, terry.reedy
Date 2015-04-18.16:47:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429375634.23.0.379524579413.issue23990@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-04-18 16:47:14ionelmcsetrecipients: + ionelmc, terry.reedy, belopolsky, christian.heimes, Claudiu.Popa, ethan.furman, llllllllll, jedwards
2015-04-18 16:47:14ionelmcsetmessageid: <1429375634.23.0.379524579413.issue23990@psf.upfronthosting.co.za>
2015-04-18 16:47:14ionelmclinkissue23990 messages
2015-04-18 16:47:13ionelmccreate