Tom Anderson wrote: > On Tue, 4 Oct 2005, Robert Kern wrote: > >>Antoon Pardon wrote: >> >>> class Tree: >>> >>> def __lt__(self, term): >>> return set(self.iteritems()) < set(term.iteritems()) >>> >>> def __eq__(self, term): >>> return set(self.iteritems()) == set(term.iteritems()) >>> >>>Would this be a correct definition of the desired behaviour? >> >>No. >> >>In [1]: {1:2} < {3:4} >>Out[1]: True >> >>In [2]: set({1:2}.iteritems()) < set({3:4}.iteritems()) >>Out[2]: False >> >>>Anyone a reference? >> >>The function dict_compare in dictobject.c . > > Well there's a really helpful answer.
Well, *I* thought it was. Maybe not "really" helpful, but certainly a healthy start. > I'm intrigued, Robert - since you > know the real answer to this question, why did you choose to tell the > Antoon that he was wrong, not tell him in what way he was wrong, certainly > not tell him how to be right, but just tell him to read the source, rather > than simply telling him what you knew? Because I *didn't* know. I *still* don't know. I just know that the implementation of __lt__ was wrong as I demonstrated by applying the given algorithm to real dictionaries. I *do* know where to find that information: the source. So I told him absolutely everything that I knew on the subject. I couldn't tell him anything more except by trudging through the details of the source myself, but I'm not particularly interested in learning those details myself, so I didn't bother. What do you want? Personalized Python tutorials delivered by candygram? A detailed comparison of the various partial ordering schemes that could have been used? My first born son? > Still, at least you told him which > file to look in. Yes, I figured it was the polite, helpful thing to do. Apparently, I shouldn't have bothered. > And if he knows python but not C, or gets lost in the > byzantine workings of the interpreter, well, that's his own fault, i > guess. It's certainly not mine. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list