Abstract constants class Constants can be accessed via .attribute or [key] and can be iterated over.
| 10 | |
| 11 | |
| 12 | class Namespace(dict): |
| 13 | """ |
| 14 | Abstract constants class |
| 15 | Constants can be accessed via .attribute or [key] and can be iterated over. |
| 16 | """ |
| 17 | def __init__(self, *args, **kwargs): |
| 18 | d = {k: k for k in args} |
| 19 | d.update(dict(kwargs.items())) |
| 20 | super().__init__(d) |
| 21 | |
| 22 | def __getattr__(self, item): |
| 23 | return self[item] |
| 24 | |
| 25 | |
| 26 | OWNER_CONST = Namespace("UNKNOWN_VAR", "UNKNOWN_MODULE") |