[Tutor] iterator question for a toy class
Rich Krauter
rmkrauter at yahoo.com
Sat Apr 23 15:30:33 CEST 2005
Kent Johnson wrote:
> Rich Krauter wrote:
>
>> 2) Or, if you really want your __eq__ method to use the iterator
>> returned by __iter__(),
>>
>> def __eq__(self, other):
>> for i, j in map(None,self, other):
>> if i != j:
>> return False
>> return True
>
>
> That's not right either, it will compare Foo([None], []) == Foo([], [])
> for example.
Kent,
Yikes, I should have seen that. Thanks for pointing out the error.
Rich
More information about the Tutor
mailing list