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
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.
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
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
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
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
[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
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)*
[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
> 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.
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
11 matches
Mail list logo