Re: dictionary interface

2005-10-06 Thread Bengt Richter
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()) set(term.iteritems())

Re: dictionary interface

2005-10-06 Thread Antoon Pardon
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 boils down to the

Re: dictionary interface

2005-10-05 Thread Antoon Pardon
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 set(self.iteritems()) ==

Re: dictionary interface

2005-10-05 Thread Paul Rubin
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

Re: dictionary interface

2005-10-05 Thread Steve Holden
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 __eq__(self, term): return

Re: dictionary interface

2005-10-05 Thread Antoon Pardon
Op 2005-10-05, Paul Rubin schreef http: 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

Re: dictionary interface

2005-10-05 Thread Paul Rubin
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. --

Re: dictionary interface

2005-10-05 Thread Paul Rubin
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

Re: dictionary interface

2005-10-05 Thread Antoon Pardon
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 compare equal.

Re: dictionary interface

2005-10-05 Thread Steve Holden
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 {} {})

Re: dictionary interface

2005-10-05 Thread Tom Anderson
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 it was. I'm sorry i was so

dictionary interface

2005-10-04 Thread Antoon Pardon
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 problem. this unittest tries to test

Re: dictionary interface

2005-10-04 Thread Robert Kern
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 problem.

Re: dictionary interface

2005-10-04 Thread Tom Anderson
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

Re: dictionary interface

2005-10-04 Thread Robert Kern
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