Message241389
| Author |
llllllllll |
| Recipients |
Claudiu.Popa, belopolsky, christian.heimes, ethan.furman, ionelmc, jedwards, llllllllll, terry.reedy |
| Date |
2015年04月18日.01:28:50 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1429320530.77.0.42065108344.issue23990@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
"The purpose of callable is to report whether an instance is callable or not"
I am totally with you so far until you get to: "and that information is available on the instance's class, via the presence of __call__". I don't understand why this assumption must be made. The following class is totally valid and callable (in the sense that I can use function call syntax on instances):
class C(object):
@property
def __call__(self):
return lambda: None
Also, I don't understand why you would mention __iter__, __iter__ respects the descriptor protocol also:
>>> class C(object):
... @property
... def __iter__(self):
... return lambda: iter(range(10))
...
>>> it = iter(C())
>>> next(it)
0
>>> next(it)
1
>>> next(it)
2 |
|