'A version of setdefault that sets sequence if appropriate.'

def setdefault(self, key, default=None):

    try:
        return self[key]
    except KeyError:
        self[key] = default
        return self[key]
