17 Jul
2002
17 Jul
'02
3:07 p.m.
On Wed, 17 Jul 2002, Clark C . Evans wrote:
Right, but such objects wouldn't be mis-leading beacuse they'd be missing a __iter__ method, correct?
Oh, i guess i didn't properly answer your question. Oops. :) My answer would be: you could say that, but wouldn't it suck to have to check for the existence of __iter__ every time you wanted to call next? You can legislate that everyone should implement __iter__ together with next; you can legislate that everyone should check for __iter__ before calling next. To some extent you have to do both or neither; one without the other is inconsistent and would lead to surprises. In practice no one's going to check. So in practice __iter__ isn't really part of the protocol. -- ?!ng