property module#
Property system#
This module provides the base Property class. Objects can be assigned properties, and properties can be retrieved from objects.
- class Property[source]#
Property base class. To declare a new property, subclass this class. Note that properties should be immutable, or care should be taken that a mutable property is not reused across multiple objects (unless intentional, of course). For example a property holding a list of things to be appended to per object should be carefully constructed so the same list is not attached to multiple objects.
>>> @dataclass(frozen=True) ... class MyProperty(Property): ... some_string_value: str
>>> other_object = object() # some object to assign property, such as a Port >>> MyProperty("abc").assign(other_object) >>> MyProperty.get(other_object) MyProperty(some_string_value="abc")