Re: help - iter & dict

2006-08-05 Thread Alistair King
thanks to Simon Forman, his solution worked, the key value pairs were entered the wrong way round in the dictionary...Doh! -- Dr. Alistair King Research Chemist, Laboratory of Organic Chemistry, Department of Chemistry, Faculty of Science P.O. Box 55 (A.I. Virtasen aukio 1) FIN-00014 University

Re: help - iter & dict

2006-08-04 Thread Alistair King
taleinat wrote: > mappi.helsinki.fi> writes: > > >> CDSitdict = {28.473823598317392: "'2.48699832'", 40.06163037274758: >> "'0.2912'", 27.756248559438422: "'2.83499964'", >> 33.2299196586726: "'1.12499962'", 29.989685187220061: >> "'1.91399677'", 31.

Re: help - iter & dict

2006-08-04 Thread Alistair King
Simon Forman wrote: > [EMAIL PROTECTED] wrote: > >> Dear Python people, >> >> im a newbie to python and here...so hello! >> > > Hi Ali, and welcome. > > >> Im trying to iterate through values in a dictionary so i can find the >> closest value and then extract the key for that valuewh

Re: help - iter & dict

2006-08-04 Thread taleinat
mappi.helsinki.fi> writes: > CDSitdict = {28.473823598317392: "'2.48699832'", 40.06163037274758: > "'0.2912'", 27.756248559438422: "'2.83499964'", > 33.2299196586726: "'1.12499962'", 29.989685187220061: > "'1.91399677'", 31.502319473614037: "'1.490

Re: help - iter & dict

2006-08-03 Thread John Machin
Something strange possessed Tim Chase and caused him to write: > def findClosest(dataset, target): [subtly *BUGGY* and overly verbose] > def findClosest2(dataset, target): [evil] Try this (tested to the extent shown): C:\junk>type dict_closest.py def findClosest(dataset, target): [snip] def find

Re: help - iter & dict

2006-08-03 Thread aking
Quoting taleinat <[EMAIL PROTECTED]>: > Ali writes: > > >> Im trying to iterate through values in a dictionary so i can find the > >> closest value and then extract the key for that valuewhat ive done > so far: > >> > >> def pcloop(dictionary, exvalue): > >> z = dictionary.itervalues

Re: help - iter & dict

2006-08-03 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Dear Python people, > > im a newbie to python and here...so hello! Hi Ali, and welcome. > Im trying to iterate through values in a dictionary so i can find the > closest value and then extract the key for that valuewhat ive done so far: > > def pcloop(dictionary, ex

Re: help - iter & dict

2006-08-03 Thread taleinat
Ali writes: >> Im trying to iterate through values in a dictionary so i can find the >> closest value and then extract the key for that valuewhat ive done so >> far: >> >> def pcloop(dictionary, exvalue): >> z = dictionary.itervalues() >> y = z - exvalue >> v = (y*y)*

Re: help - iter & dict

2006-08-03 Thread Justin Azoff
[EMAIL PROTECTED] wrote: > Im trying to iterate through values in a dictionary so i can find the > closest value and then extract the key for that valuewhat ive done so far: [snip] > short time. I was trying to define a function (its my first!) so that i > could apply to several 'dictionary's a

Re: help - iter & dict

2006-08-03 Thread Tim Chase
> Im trying to iterate through values in a dictionary so i can find the > closest value and then extract the key for that valuewhat ive done so far: > > def pcloop(dictionary, exvalue): > z = dictionary.itervalues() > y = z - exvalue > v = (y*y)**1/2 > if v < 0.

help - iter & dict

2006-08-03 Thread aking
Dear Python people, im a newbie to python and here...so hello! Im trying to iterate through values in a dictionary so i can find the closest value and then extract the key for that valuewhat ive done so far: def pcloop(dictionary, exvalue): z = dictionary.itervalues() y = z