📜  python 不可变数据类 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:29.551000             🧑  作者: Mango

代码示例1
# truly immutable Python objects are not possible, 
# but it's simulated by throwing an exception if you want to set fields
from dataclasses import dataclass

@dataclass(frozen=True)
class MyImmutableData:
    immutable_field: str