def with_defaults(cls, *args, **kwargs):
        """Return an instance with defaults populated as necessary."""
        # XXX or dynamically build this method with appropriate signature
        for field, arg in zip(fields, args):
            if field in kwargs:
                raise TypeError("with_defaults() got multiple values for "
                                "keyword argument {!r}".format(field))
            kwargs[field] = arg
        for field, default in defaults.items():
            if field not in kwargs:
                kwargs[field] = default
        if global_default_arg:
            default = global_default_arg[0]
            for field in fields:
                if field not in kwargs:
                    kwargs[field] = default
        return cls(**kwargs)
Return an instance with defaults populated as necessary.
recipes/Python/578456_class_decorator_creating_named/recipe-578456.py