[EMAIL PROTECTED] wrote: > Sorry Fredrik but I don't understand. Just comment out the assert and > you have different results depending on whether an unrelated sort > function is defined. > This seems weird to me !
code snippet: > from random import choice > class OBJ: > def __init__(self,identifier): > self.id=identifier > self.allocated=0 # Your problem begins here... > def __cmp__(self,other): # it continues here > return cmp(other.allocated,self.allocated) > mylist=[OBJ(i) for i in range(20)] > excluded=[obj for obj in mylist if obj.id>choice(range(20))] > for obj in mylist: > if obj in excluded: # and you see it in action here > assert obj.id in [objt.id for objt in excluded] > continue How do you think the "membership" test works ? Could it be possible that it uses the __cmp__ method ? And if so, how do you think your instances will compare knowing that your __cmp__ method will return equality for all the instances in this snippet ? Just change your __init__ method to: def __init__(self,identifier): self.id=identifier self.allocated=identifier and rerun the test. I don't think this is a bug... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list