f | def sloter(fields, default): | f | def sloter(fields, default): |
| | | |
n | class cls: | n | class gen_class: |
| __slots__ = fields | | __slots__ = fields |
| | | |
| def __init__(self): | | def __init__(self): |
n | for i in self.__slots__: | n | for field in self.__slots__: |
| setattr(self, i, default) | | setattr(self, field, default) |
| | | |
| def __iter__(self): | | def __iter__(self): |
n | for i in self.__slots__: | n | for field in self.__slots__: |
| if hasattr(self, i): | | if hasattr(self, field): |
| yield getattr(self, i) | | yield getattr(self, field) |
| | | |
| def __delattr__(self, field): | | def __delattr__(self, field): |
| if hasattr(self, field): | | if hasattr(self, field): |
| setattr(self, field, default) | | setattr(self, field, default) |
t | return cls | t | return gen_class |