[Tutor] Dict operation question.
David Driver
count0.djd at gmail.com
Thu Jul 7 17:33:52 CEST 2005
I have a function
def updateit(self,**mydict):
which is intended to update a dictionary self.somedict.
If there are keys in mydict that are not in self.somedict I want them
returned in a new dict.
here is what i am doing now:
errdict = dict([(a,b) for a,b in mydict.items() if not a in self.somedict])
I then test (if errdict) and raise an exception that contains errdict
as an attribute. Else i update self.somedict.
Is there something other than a list comprehension in a dict function
that can do this?
Thanks!
--
***********************************
See there, that wasn't so bad.
***********************************
More information about the Tutor
mailing list