n | class Mixed: | n | class Combined: |
| | | |
n | def __init__(self, *objects): | n | def __init__(self, *components): |
| for obj in objects: | | for component in components: |
| for attr in dir(obj): | | for attribute in dir(component): |
| if not attr.startswith('_'): | | if not attribute.startswith('_'): |
| value = getattr(obj, attr) | | value = getattr(component, attribute) |
| if not callable(value): | | if not callable(value): |
n | setattr(self, attr, value) | n | setattr(self, attribute, value) |
| | | |
n | def __str__(self): | n | def __repr__(self): |
| attrs = {k: v for k, v in self.__dict__.items()} | | properties = {key: value for key, value in vars(self).items()} |
| sorted_attrs = sorted(attrs.items()) | | ordered_properties = sorted(properties.items()) |
| return ', '.join((f'{k}={v}' for k, v in sorted_attrs)) | | return ', '.join((f'{key}={value}' for key, value in ordered_pro |
| | | perties)) |
| | | |
t | def mix(*objects): | t | def mix(*components): |
| return Mixed(*objects) | | return Combined(*components) |