| t | class Generative(type): | t | class Generative(type): |
| _creation_index = 0 | | _creation_index = 0 |
| | | |
| class OrderTracker: | | class OrderTracker: |
| | | |
| def __get__(self, obj, owner): | | def __get__(self, obj, owner): |
| return Generative._creation_index | | return Generative._creation_index |
| | | |
| def __new__(mcls, class_name, bases_tuple, namespace_dict): | | def __new__(mcls, class_name, bases_tuple, namespace_dict): |
| namespace_dict['generation'] = Generative.OrderTracker() | | namespace_dict['generation'] = Generative.OrderTracker() |
| cls = super().__new__(mcls, class_name, bases_tuple, namespace_d | | cls = super().__new__(mcls, class_name, bases_tuple, namespace_d |
| ict) | | ict) |
| Generative._creation_index += 1 | | Generative._creation_index += 1 |
| return cls | | return cls |
| | | |
| def __setattr__(cls, attrib_name, value): | | def __setattr__(cls, attrib_name, value): |
| if attrib_name == 'generation': | | if attrib_name == 'generation': |
| raise AttributeError('generation is a constant, read-only pr | | raise AttributeError('generation is a constant, read-only pr |
| operty') | | operty') |
| super().__setattr__(attrib_name, value) | | super().__setattr__(attrib_name, value) |
| | | |
| def __delattr__(cls, attrib_name): | | def __delattr__(cls, attrib_name): |
| if attrib_name == 'generation': | | if attrib_name == 'generation': |
| raise AttributeError('cannot destroy the generation attribut | | raise AttributeError('cannot destroy the generation attribut |
| e') | | e') |
| super().__delattr__(attrib_name) | | super().__delattr__(attrib_name) |