Message241426
| 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. |
|