def __init__(self, **kwargs):
        defaults = self.keywords_to_init_defaults()
        # Make a copy in case defaults is a reference to a global object.
        values = defaults.copy()
        values.update(kwargs)
        if len(values) != len(defaults):
            # Then there is at least one invalid keyword.
            valid = sorted(defaults.keys())
            invalid = sorted(set(values.keys()) - set(valid))
            raise TypeError("invalid keyword argument(s): {0} (valid are: {1})".
                            format(", ".join(repr(k) for k in invalid),
                                   ", ".join(valid)))
        attrs = self.keywords_to_attrs()
        for keyword, value in values.items():
            attr = attrs[keyword]
            setattr(self, attr.name, value)
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/jsonlib.py/JsonableMixin.__init__/original