Op 2005-10-05, Steve Holden schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-10-05, Steve Holden schreef <[EMAIL PROTECTED]>:
> [...]
>>
>> Anyway, I have searched the source of the test for all testing
>> with regards to < and after some browsing back and fore it seems
>> it all boi
On 5 Oct 2005 08:23:53 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:
>Op 2005-10-05, Tom Anderson schreef <[EMAIL PROTECTED]>:
>> On Tue, 4 Oct 2005, Robert Kern wrote:
>>
>>> Antoon Pardon wrote:
>>>
class Tree:
def __lt__(self, term):
return set(self.iteritems())
On Tue, 4 Oct 2005, Robert Kern wrote:
> Tom Anderson wrote:
>> On Tue, 4 Oct 2005, Robert Kern wrote:
>>
>>> Antoon Pardon wrote:
>>>
Anyone a reference?
>>>
>>> The function dict_compare in dictobject.c .
>>
>> Well there's a really helpful answer.
>
> Well, *I* thought it was.
And indeed
Antoon Pardon wrote:
> Op 2005-10-05, Steve Holden schreef <[EMAIL PROTECTED]>:
[...]
>
> Anyway, I have searched the source of the test for all testing
> with regards to < and after some browsing back and fore it seems
> it all boils down to the following two tests.
>
>self.assert_(not {} <
Op 2005-10-05, Steve Holden schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>>
>> I have been searching some more and finally stumbled on this:
>>
>> http://docs.python.org/ref/comparisons.html
>>
>> Mappings (dictionaries) compare equal if and only if their sorted
>> (key, value) lists
Antoon Pardon <[EMAIL PROTECTED]> writes:
> My tree class is almost finished, but one unittest still fails,
> is this a failing of my class (as a replacement for a dictionary)
> or is this a non-required characteristic of dictionaries?
If it were me, I'd treat the language reference manual as
auth
Steve Holden <[EMAIL PROTECTED]> writes:
> I can't help wondering, though, under what conditions it actually
> makes sense to compare two dictionaries for anything other than
> equality.
You might want to sort a bunch of dictionaries to bring the equal ones
together.
--
http://mail.python.org/mai
Op 2005-10-05, Paul Rubin schreef :
> Antoon Pardon <[EMAIL PROTECTED]> writes:
>> But that is contradicted by the unittest. If you have a unittest for
>> comparing dictionaries, that means comparing dictionaries has a
>> testable characteristic and thus is further defined.
>
> No, I don't think so
Antoon Pardon wrote:
> Op 2005-10-05, Tom Anderson schreef <[EMAIL PROTECTED]>:
>
>>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 __
Antoon Pardon <[EMAIL PROTECTED]> writes:
> But that is contradicted by the unittest. If you have a unittest for
> comparing dictionaries, that means comparing dictionaries has a
> testable characteristic and thus is further defined.
No, I don't think so. The unittest makes sure that a particular
Op 2005-10-05, Tom Anderson schreef <[EMAIL PROTECTED]>:
> 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 se
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(
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 co
Antoon Pardon wrote:
> I'm writing a Tree class, which should behave a lot like a dictionary.
>
> In order to test this, I took the unittest from the source distribution
> for dictionaries and used it to test against my Tree class.
>
> Things are working out rather well, but I stumbled on a probl
14 matches
Mail list logo