jangada.mixin.Identifiable.id#
- Identifiable.id: str#
Globally unique identifier (UUID v4).
A 32-character hexadecimal UUID v4 string that uniquely identifies this instance. Automatically generated on first access if not explicitly provided. Write-once (cannot be changed after initialization) and non-copiable (each copy gets a new ID).
See also
Identifiable.get_instanceRetrieve instance by ID
Notes
The ID serves as the basis for
__hash__()and__eq__(), enabling instances to be used in sets and as dictionary keys. Objects with the same ID are considered equal.Examples
Automatic generation:
obj = Identifiable() print(obj.id) # '3a5f8e2c1b9d4f7a0b1c2d3e4f5a6b7c'
Explicit setting (during deserialization):
# ID is validated and normalized obj.id = 'A1B2C3D4-E5F6-4789-ABCD-EF0123456789'
Immutability:
obj = Identifiable() obj.id = 'different-id' # Raises AttributeError
Lookup by ID:
obj_id = obj.id retrieved = Identifiable.get_instance(obj_id) assert retrieved is obj