def kadd(self, key, value):
        """Adds the given key/value to all elements.
        Single values for a key are stored directly, as key:value, multiple
        values for the same key are stored as key,set(values).
        """
        for item in self:
            try:
                # Use the key as a set
                item[key].add(value)
            except KeyError:
                # This happens if the key is not present
                item[key] = value
            except AttributeError:
                # This happens if the key is present but is not a set
                item[key] = set([item[key], value])
def kadd ( self , key , value ) : for item in self : try : item [ key ] . add ( value ) except KeyError : item [ key ] = value except AttributeError : item [ key ] = set ( [ item [ key ] , value ] )
Adds the given key/value to all elements.
        Single values for a key are stored directly, as key:value, multiple
        values for the same key are stored as key,set(values).