def setdefault(self, key, default):
        """
        If 'key' doesn't exist, associate it with the 'default' value.
        Return value associated with 'key'.
        """
        if not self.has_key(key):
            self[key] = default
        return self[key]

        If 'key' doesn't exist, associate it with the 'default' value.
        Return value associated with 'key'.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/util.py