Re: Why aren't OrderedDicts comparable with < etc?

2009-07-25 Thread Piet van Oostrum
> Albert van der Horst (AvdH) wrote: >AvdH> With regard to < and > you are right. >AvdH> But I think there is a sensible == w.r.t. dict's. >AvdH> It is to mean that for each key dict1(key) == dict2(key) >AvdH> (implying that their key set must be the same) >AvdH> [I could have used that fo

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-25 Thread Albert van der Horst
In article , Jack Diederich wrote: >On Mon, Jul 20, 2009 at 10:00 AM, Steven >D'Aprano wrote: >> On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: >> >>> Terry Reedy =A0 wrote: Sion Arrowsmith wrote: > Jack Diederich =A0 wrote: >> It isn't an OrderedDict thing, it is a compar

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-20 Thread Jack Diederich
On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Aprano wrote: > On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: > >> Terry Reedy   wrote: >>>Sion Arrowsmith wrote: Jack Diederich   wrote: > It isn't an OrderedDict thing, it is a comparison thing.  Two regular > dicts also raise a

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-20 Thread Steven D'Aprano
On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: > Terry Reedy wrote: >>Sion Arrowsmith wrote: >>> Jack Diederich wrote: It isn't an OrderedDict thing, it is a comparison thing. Two regular dicts also raise an error if you try to LT them. >>> Python 2.5.2 >> d1 = dict(

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-20 Thread Sion Arrowsmith
Terry Reedy wrote: >Sion Arrowsmith wrote: >> Jack Diederich wrote: >>> It isn't an OrderedDict thing, it is a comparison thing. Two regular >>> dicts also raise an error if you try to LT them. >> Python 2.5.2 > d1 = dict((str(i), i) for i in range (10)) > d2 = dict((str(i), i) for i i

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-17 Thread Terry Reedy
Sion Arrowsmith wrote: Jack Diederich wrote: It isn't an OrderedDict thing, it is a comparison thing. Two regular dicts also raise an error if you try to LT them. Since when? Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "lice

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-17 Thread Sion Arrowsmith
Jack Diederich wrote: >It isn't an OrderedDict thing, it is a comparison thing. Two regular >dicts also raise an error if you try to LT them. Since when? Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Nobody
On Thu, 16 Jul 2009 03:59:47 -0700, Mark wrote: >> > Or maybe not. If OrderedDicts are sequences as well as mappings, then we >> > should be able to sort them. And that seems a bit much even for me. >> One thing that I've just noticed is that you can use <, <=, >=, and > >> with sets: >> It seem

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Terry Reedy
Mark wrote: On 16 July, 10:21, Piet van Oostrum wrote: But why should the order be as if the OrderedDict was a list of tuples. A dict can be considered as a mapping and then you might want to treat either the key or the value as contravariant (the key I guess). So there is ambiguity. Why woul

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Mark
On 16 July, 11:58, Mark wrote: > On 16 July, 08:51, Steven D'Aprano > > > > wrote: > > On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > > > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > > > wrote: > > >> Hi, > > > >> I'm just wondering why <, <=, >=, and > are not supported by > >

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Mark
On 16 July, 08:51, Steven D'Aprano wrote: > On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > > wrote: > >> Hi, > > >> I'm just wondering why <, <=, >=, and > are not supported by > >> collections.OrderedDict: > > >>    >>> d1 = collec

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Mark
On 16 July, 10:21, Piet van Oostrum wrote: > > Mark (M) wrote: > >M> You are right that it doesn't make sense to compare two dicts. > >M> But OrderedDicts can be viewed logically as lists of (key,value) > >M> tuples so they are much more like lists or tuples when it comes to > >M> comparisons

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Piet van Oostrum
> Mark (M) wrote: >M> You are right that it doesn't make sense to compare two dicts. >M> But OrderedDicts can be viewed logically as lists of (key,value) >M> tuples so they are much more like lists or tuples when it comes to >M> comparisons. >M> For example: > l = [("a", 1), ("z", 2),

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Steven D'Aprano
On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: > On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield > wrote: >> Hi, >> >> I'm just wondering why <, <=, >=, and > are not supported by >> collections.OrderedDict: >> >>    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) d2 = >>  

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Chris Rebert
On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfield wrote: > Hi, > > I'm just wondering why <, <=, >=, and > are not supported by > collections.OrderedDict: > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >    >>> d2 = d1.copy() >    >>> d2["z"] = 4 >    >>> d1 == d2 >    False >

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Mark
On 16 July, 08:12, Jack Diederich wrote: > On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfield wrote: > > Hi, > > > I'm just wondering why <, <=, >=, and > are not supported by > > collections.OrderedDict: > > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) > >    >>> d2 = d1.copy()

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Jack Diederich
On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfield wrote: > Hi, > > I'm just wondering why <, <=, >=, and > are not supported by > collections.OrderedDict: > >    >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >    >>> d2 = d1.copy() >    >>> d2["z"] = 4 >    >>> d1 == d2 >    False >  

Why aren't OrderedDicts comparable with < etc?

2009-07-15 Thread Mark Summerfield
Hi, I'm just wondering why <, <=, >=, and > are not supported by collections.OrderedDict: >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >>> d2 = d1.copy() >>> d2["z"] = 4 >>> d1 == d2 False >>> d1 < d2 Traceback (most recent call last): File "", line