[Tutor] Dict operation question.

Javier Ruere javier at ruere.com.ar
Fri Jul 8 04:08:47 CEST 2005


I should also add the most simple and obvious implementation which is also the fastest:


class Test:
    def __init__(self, dict):
        self.somedict = dict

    def updateit(self, **mydict):
        errdict = {}
        for k, v in mydict.iteritems():
            if k not in self.somedict:
                self.somedict[k] = v
                errdict[k] = v

        if (not errdict):
            raise Exception(errdict)



More information about the Tutor mailing list