AnalysisToolbox
AnalysisToolbox copied to clipboard
constants class?
If you are not careful with lists, you can accidentally change variables without meaning to through shallow copies. Is there a way to implement a constants class that can't be accidentally modified?
Maybe something like this: https://discuss.dizzycoding.com/can-i-prevent-modifying-an-object-in-python/
I do that usually like this:
from typing import NamedTuple
class test(NamedTuple):
blub: int
bla: float
this_test = test(4, 3.2)
this_test.blub = 5 # this will fail, because it's immutable.
This can be used to pass one immutable "parameter object" to a function, instead of passing lots of single parameter which are then also mutable.