f | class MixedObject: | f | class MixedObject: |
| | | |
| def __init__(self, **kwargs): | | def __init__(self, **kwargs): |
| self.__dict__.update(kwargs) | | self.__dict__.update(kwargs) |
| | | |
| def __str__(self): | | def __str__(self): |
| sorted_items = sorted(self.__dict__.items()) | | sorted_items = sorted(self.__dict__.items()) |
n | return ', '.join((f'{k}={v}' for k, v in sorted_items)) | n | return ', '.join((f'{key}={value}' for key, value in sorted_item |
| | | s)) |
| | | |
t | def mix(*args): | t | def mix(*objects): |
| result = {} | | fields = {} |
| for obj in args: | | for obj in objects: |
| for attr in dir(obj): | | for key in dir(obj): |
| if not attr.startswith('_') and (not callable(getattr(obj, a | | if not key.startswith('_') and (not callable(getattr(obj, ke |
| ttr))): | | y))): |
| result[attr] = getattr(obj, attr) | | fields[key] = getattr(obj, key) |
| return MixedObject(**result) | | return MixedObject(**fields) |