dictionary interface

Antoon Pardon apardon at forel.vub.ac.be
Thu Oct 6 04:46:34 EDT 2005


Op 2005-10-05, Steve Holden schreef <steve at holdenweb.com>:
> Antoon Pardon wrote:
>> Op 2005-10-05, Steve Holden schreef <steve at holdenweb.com>:
> [...]
>> 
>> 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 {} < {})
>>    self.assert_(not {1: 2} < {1L: 2L})
>> 
>
> So there isn't much to do, then! That's good. Seems you can pretty much 
> choose your own ordering.

Yes, I must have misunderstood something because I thought there also
was the following test:

  self.assert_({} < {1: 2})

Which is what prompted this thread from me.

> It would seem sensible to test a third case, namely
>
>      self.assert_(not {1L: 2L} < {1: 2})

I also though about adding the following test.

  dlst = range(20)
  for i in xrange(20):
    dlst[i] = some_ramdom_dict()
  sort(dlst)
  for i in xrange(19):
    for j in xrange(i+1,20):
      self.assert_(dlst[i] < dlst[j])


This would test for the consistency of the order, so that if a < b
and b < c that we also have a < c.

What do you think?

-- 
Antoon Pardon



More information about the Python-list mailing list