Re: dictionary interface
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: dictionary interface

From: Antoon Pardon <apardon@forel.vub.ac.be>
Date: Thu Oct 06 2005 - 10:46:34 CEST

Op 2005-10-05, Steve Holden schreef <steve@holdenweb.com>:
> Antoon Pardon wrote:
>> Op 2005-10-05, Steve Holden schreef <steve@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
Received on Sat Oct 15 04:12:41 2005