bazi.defines.enum_base
领域枚举的共同行为。
BaziEnum 提供领域枚举基类,IndexedBaziEnum 另提供索引访问。
-
class bazi.defines.enum_base.BaziEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]
领域枚举的公共基类,共用 from_str / as_list / __str__。
子类钩子必须是描述符(如 classmethod);Enum 类体中的普通类属性会成为枚举成员。
-
classmethod as_list() → list[Self][源代码]
-
classmethod from_str(s: str) → Self[源代码]
-
class bazi.defines.enum_base.IndexedBaziEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]
在 BaziEnum 之上提供 O(1) 的定义序下标(index / from_index)。
-
classmethod as_list() → list[Self][源代码]
-
classmethod from_index(i: int) → Self[源代码]
按定义序取成员,下标语义同 list:负数回绕,越界抛 IndexError。
-
classmethod from_str(s: str) → Self[源代码]
-
property index: int[源代码]