n | class Mix: | n | class MixNamespace: |
| | | |
| def __init__(self, **kwargs): | | def __init__(self, **kwargs): |
| self.__dict__.update(kwargs) | | self.__dict__.update(kwargs) |
| | | |
| def __str__(self): | | def __str__(self): |
n | items = sorted(((k, v) for k, v in self.__dict__.items() if not | n | fields = sorted(((key, value) for key, value in self.__dict__.it |
| k.startswith('_'))) | | ems() if not key.startswith('_'))) |
| return ', '.join((f'{k}={v}' for k, v in items)) | | return ', '.join((f'{key}={value}' for key, value in fields)) |
| | | |
| def mix(*args): | | def mix(*args): |
n | combined = {} | n | combined_fields = {} |
| for obj in args: | | for obj in args: |
t | for key in dir(obj): | t | for name in dir(obj): |
| if not key.startswith('_') and (not callable(getattr(obj, ke | | if not name.startswith('_') and (not callable(getattr(obj, n |
| y))): | | ame))): |
| combined[key] = getattr(obj, key) | | combined_fields[name] = getattr(obj, name) |
| return Mix(**combined) | | return MixNamespace(**combined_fields) |