def getsetitem(self, key, klass, args=None, kwdargs=None):
        """This is similar to setdefault(), except that the new value is
        created by instantiating _klass_.  This prevents you from having
        to create an object and initialize it and then throw it away if
        there is already a dictionary item of that type.
        """

        with self.lock:
            if key in self:
                return self.getitem(key)

            # Instantiate value.
            if not args:
                args = []
            if not kwdargs:
                kwdargs = {}
            value = klass(*args, **kwdargs)

            self.setitem(key, value)
            return value
def getsetitem ( self , key , klass , args = None , kwdargs = None ) : with self . lock : if key in self : return self . getitem ( key ) if not args : args = [ ] if not kwdargs : kwdargs = { } value = klass ( * args , ** kwdargs ) self . setitem ( key , value ) return value
This is similar to setdefault(), except that the new value is
        created by instantiating _klass_.  This prevents you from having
        to create an object and initialize it and then throw it away if
        there is already a dictionary item of that type.