From: ddainese40x at x44dsi.unive.it (Diego Dainese)
Date: 10 May 1999 18:03:48 GMT
Subject: dictionary object
Message-ID: <slrn7je7s3.6n.diego@blanka2.blankanet.it>
X-UID: 1907                                                 

Hi,

I have a question regarding the dictionary objects: in a dictionary
where the values are tuples, is it possible to get the tuple with a
given key and to change the value of one element of this tuple using
only one key lookup?

In example, if dict is defined like this:

   value1 = "hello one"
   value2 = "hello two"
   dict = { "pluto" : (10, value1), "pippo" : (20, value2) }

And I want to get the first element of the tuple with the key "pluto"
and change the second element of this same tuple, I must do something
like this:

  num = dict["pluto"][0]
  dict["pluto"]= (num, "hello three")

Thus making two key lookups. There is a better way to do it?

Thanks in advance,

-- 
Diego Dainese
To reply me, remove the numbers and the `x' from my address
Sorry for my bad English!




