Re: comparing dictionaries

2008-05-08 Thread Terry Reedy
"Miki" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, > I want to compare two dicts that should have identical info just in a > different data structure. The first dict's contents look like this. It > is authoritative... I know for sure it has the correct key value pairs: > >

Re: comparing dictionaries

2008-05-07 Thread Miki
Hello, > I want to compare two dicts that should have identical info just in a > different data structure. The first dict's contents look like this. It > is authoritative... I know for sure it has the correct key value pairs: > > {'001' : '01'} > > The second dict's contents are like this with a t

Re: comparing dictionaries

2008-05-07 Thread Arnaud Delobelle
brad <[EMAIL PROTECTED]> writes: > I want to compare two dicts that should have identical info just in a > different data structure. The first dict's contents look like this. It > is authoritative... I know for sure it has the correct key value > pairs: > > {'001' : '01'} -> refdict > > The seco

Re: comparing dictionaries

2008-05-07 Thread Carsten Haese
brad wrote: I want to compare two dicts that should have identical info just in a different data structure. The first dict's contents look like this. It is authoritative... I know for sure it has the correct key value pairs: {'001' : '01'} The second dict's contents are like this with a tuple

Re: comparing dictionaries

2008-05-07 Thread cokofreedom
On May 7, 4:08 pm, brad <[EMAIL PROTECTED]> wrote: > I want to compare two dicts that should have identical info just in a > different data structure. The first dict's contents look like this. It > is authoritative... I know for sure it has the correct key value pairs: > > {'001' : '01'} > > The se

Re: comparing dictionaries to find the identical keys

2007-12-28 Thread Christian Heimes
Beema shafreen wrote: > hi everybody , > i need to compare two dictionary's key. I have written a script Use sets. Sets are easier to use and much faster: >>> d1 = {'a': 1, 'b': 2, 'c': 3} >>> d2 = {'b': 2, 'c': 3, 'd': 4} >>> d1.keys() ['a', 'c', 'b'] >>> d2.keys() ['c', 'b', 'd'] >>> s1 = set(

Re: comparing dictionaries to find the identical keys

2007-12-28 Thread km
Hi On Dec 28, 2007 4:55 PM, Beema shafreen <[EMAIL PROTECTED]> wrote: > hi everybody , > i need to compare two dictionary's key. I have written a script > gene_symbol = {} > probe_id = {} > result = {} > def getGene(fname): > fh = open(fname , 'r') > for line in fh: >

Re: Comparing Dictionaries

2007-07-31 Thread Alex Martelli
Kenneth Love <[EMAIL PROTECTED]> wrote: ... > Python in a Nutshell (2nd ed.) ... > I am a slow reader. So, if Doctests are mentioned in any of the above, > I haven't encountered it yet. Yep, I cover doctest in the chapter on testing, debugging, profiling and optimizing. Alex -- http://ma

Re: Fwd: Re: Comparing Dictionaries

2007-07-30 Thread Steven D'Aprano
On Mon, 30 Jul 2007 14:06:29 -0500, Kenneth Love wrote: > >>From: "Steven D'Aprano" <[EMAIL PROTECTED]> >>Newsgroups: comp.lang.python >>Subject: Re: Comparing Dictionaries >>Date: Sat, 28 Jul 2007 10:21:14 +1000 >>To: python-list@python.org

Re: Comparing Dictionaries

2007-07-30 Thread Paul Rubin
Kenneth Love <[EMAIL PROTECTED]> writes: > I will search on Google for more info on Doctest. Doctest is recent. Try: http://python.org/doc/lib/module-doctest.html Diveintopython should probably be updated to use doctest instead of unittest. unittest is Java-descended and doesn't fit into Pytho

Re: Comparing Dictionaries

2007-07-30 Thread Paddy
On Jul 30, 8:30 pm, Kenneth Love <[EMAIL PROTECTED]> wrote: > At 03:23 AM 7/28/2007, you wrote: > > >Hi Kenneth, being new to Python i wondered if you at least considered > >Doctests as part of your testing solution. > >Other languages don't have Doctest. > > >- Paddy. > > Until I read your post,

Re: Comparing Dictionaries

2007-07-30 Thread Kenneth Love
At 03:23 AM 7/28/2007, you wrote: >Hi Kenneth, being new to Python i wondered if you at least considered >Doctests as part of your testing solution. >Other languages don't have Doctest. > >- Paddy. Until I read your post, I had never even heard of Doctest. I will look into it. Here is the list

Fwd: Re: Comparing Dictionaries

2007-07-30 Thread Kenneth Love
>From: "Steven D'Aprano" <[EMAIL PROTECTED]> >Newsgroups: comp.lang.python >Subject: Re: Comparing Dictionaries >Date: Sat, 28 Jul 2007 10:21:14 +1000 >To: python-list@python.org > >On Fri, 27 Jul 2007 14:11:02 -0500, Kenneth Love wrote: > > > T

Re: Comparing Dictionaries

2007-07-28 Thread Martin P. Hellwig
Kenneth Love wrote: > That should teach me not to change working code at the same time I am > writing unit tests. Even so, I realize it won't be the last time I > do something so silly. Yes, I know about TDD's "write the test first", > but I'm not comfortable with the philosophy of these new fan

Re: Comparing Dictionaries

2007-07-28 Thread Paddy
Hi Kenneth, being new to Python i wondered if you at least considered Doctests as part of your testing solution. Other languages don't have Doctest. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing Dictionaries

2007-07-27 Thread Steven D'Aprano
On Fri, 27 Jul 2007 14:11:02 -0500, Kenneth Love wrote: > The published recipe (based on ConfigParser) did not handle my INI > files. I have periods in both the section names and the key names. > The INI files contents were developed according to an internally > defined process that other non-Pyt

Re: Comparing Dictionaries

2007-07-27 Thread Kenneth Love
At 09:55 PM 7/26/2007, Ben Finney wrote: >Kenneth Love <[EMAIL PROTECTED]> writes: > > > In other words, I consider these two dictionaries to be equivalent: > > > > { 'dog' : 'bone', 'cat' : 'fever', 'mouse' : 'mickey' } > > { 'mouse' : 'mickey', 'dog' : 'bone', 'cat' : 'fever' } > > > > wh

Re: Comparing Dictionaries

2007-07-27 Thread Kenneth Love
At 04:42 AM 7/27/2007, Ali wrote: >On Jul 26, 10:18 pm, Kenneth Love <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I am new to Python, but not programming. I would like to start my > > Python career by developing programs according to the "best practices" > > of the industry. Right now, that appe

Re: Comparing Dictionaries

2007-07-27 Thread Ali
On Jul 26, 10:18 pm, Kenneth Love <[EMAIL PROTECTED]> wrote: > Hello, > > I am new to Python, but not programming. I would like to start my > Python career by developing programs according to the "best practices" > of the industry. Right now, that appears to be unit tests, patterns, > and source

Re: Comparing Dictionaries

2007-07-26 Thread Ben Finney
Kenneth Love <[EMAIL PROTECTED]> writes: > In other words, I consider these two dictionaries to be equivalent: > > { 'dog' : 'bone', 'cat' : 'fever', 'mouse' : 'mickey' } > { 'mouse' : 'mickey', 'dog' : 'bone', 'cat' : 'fever' } > > while these two are not: > > { 'dog' : 'bone', 'ca

Re: Comparing dictionaries, is this valid Python?

2005-12-13 Thread Mike Meyer
François Pinard <[EMAIL PROTECTED]> writes: > Would someone know where I could find a confirmation that comparing > dictionaries with `==' has the meaning one would expect (even this is > debatable!), that is, same set of keys, and for each key, same values? It may not exist, so you'll have to go

Re: Comparing dictionaries, is this valid Python?

2005-12-13 Thread François Pinard
[Peter Hansen] >> it only says "Comparison operations are supported by all objects" >> [...] >I'm not checking the 2.3.5 version, but that latest one is fairly clear >on what comparisons on mappings do: >http://docs.python.org/ref/comparisons.html Yes, indeed. Thanks a lot! -- François Pin

Re: Comparing dictionaries, is this valid Python?

2005-12-13 Thread Peter Hansen
François Pinard wrote: > As for: > >http://www.python.org/doc/2.3.5/lib/comparisons.html > > it only says "Comparison operations are supported by all objects", which > is a little vague, and no promise that comparisons are meaningful (for > example, one might wonder what would exactly mean

Re: Comparing dictionaries, is this valid Python?

2005-12-13 Thread Tim Peters
[François Pinard] ... > Would someone know where I could find a confirmation that comparing > dictionaries with `==' has the meaning one would expect (even this is > debatable!), that is, same set of keys, and for each key, same values? Yes, look here : it has the meaning you expect, provided tha