Re: Why aren't OrderedDicts comparable with etc?

2009-07-25 Thread Albert van der Horst
In article mailman.3457.1248158525.8015.python-l...@python.org, Jack Diederich jackd...@gmail.com wrote: On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: Terry Reedy =A0tjre...@udel.edu

Re: Why aren't OrderedDicts comparable with etc?

2009-07-25 Thread Piet van Oostrum
Albert van der Horst alb...@spenarnc.xs4all.nl (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

Re: Why aren't OrderedDicts comparable with etc?

2009-07-21 Thread Jack Diederich
On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: Terry Reedy  tjre...@udel.edu wrote: Sion Arrowsmith wrote: Jack Diederich  jackd...@gmail.com wrote: It isn't an OrderedDict thing, it is a

Re: Why aren't OrderedDicts comparable with etc?

2009-07-20 Thread Sion Arrowsmith
Terry Reedy tjre...@udel.edu wrote: Sion Arrowsmith wrote: Jack Diederich jackd...@gmail.com 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 =

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 tjre...@udel.edu wrote: Sion Arrowsmith wrote: Jack Diederich jackd...@gmail.com 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

Re: Why aren't OrderedDicts comparable with etc?

2009-07-17 Thread Sion Arrowsmith
Jack Diederich jackd...@gmail.com 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

Re: Why aren't OrderedDicts comparable with etc?

2009-07-17 Thread Terry Reedy
Sion Arrowsmith wrote: Jack Diederich jackd...@gmail.com 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,

Why aren't OrderedDicts comparable with etc?

2009-07-16 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 pyshell#6, line 1, in module

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Jack Diederich
On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfieldl...@qtrac.plus.com 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     d1 d2    

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Mark
On 16 July, 08:12, Jack Diederich jackd...@gmail.com wrote: On Thu, Jul 16, 2009 at 2:21 AM, Mark Summerfieldl...@qtrac.plus.com 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 Summerfieldl...@qtrac.plus.com 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     d1 d2    

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Piet van Oostrum
Mark l...@qtrac.plus.com (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), (k,

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Mark
On 16 July, 10:21, Piet van Oostrum p...@cs.uu.nl wrote: Mark l...@qtrac.plus.com (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

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Mark
On 16 July, 08:51, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfieldl...@qtrac.plus.com 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, 11:58, Mark l...@qtrac.plus.com wrote: On 16 July, 08:51, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Thu, 16 Jul 2009 00:30:26 -0700, Chris Rebert wrote: On Wed, Jul 15, 2009 at 11:21 PM, Mark Summerfieldl...@qtrac.plus.com wrote: Hi, I'm just

Re: Why aren't OrderedDicts comparable with etc?

2009-07-16 Thread Terry Reedy
Mark wrote: On 16 July, 10:21, Piet van Oostrum p...@cs.uu.nl 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

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 seems a bit