Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python immutable dataclass

# 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
 
PREVIOUS NEXT
Tagged: #python #immutable #dataclass
ADD COMMENT
Topic
Name
3+8 =