Дзюба Мария, 517 MetaBool 17114 | Юань Дунлян, 523 Группа MetaBool 17373 | ||||
---|---|---|---|---|---|
f | 1 | class empty(type): | f | 1 | class empty(type): |
2 | 2 | ||||
3 | def __new__(cls, name, bases, dct): | 3 | def __new__(cls, name, bases, dct): | ||
n | 4 | new_cls = super().__new__(cls, name, bases, dct) | n | 4 | x = super().__new__(cls, name, bases, dct) |
5 | 5 | ||||
n | 6 | def check_if_empty(self): | n | 6 | def __bool__(self): |
7 | for attr in vars(self).values(): | 7 | for attr in self.__dict__.values(): | ||
8 | if not attr: | 8 | if not attr: | ||
9 | return False | 9 | return False | ||
10 | return True | 10 | return True | ||
t | 11 | new_cls.__bool__ = check_if_empty | t | 11 | x.__bool__ = __bool__ |
12 | return new_cls | 12 | return x |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|