jangada.mixin.Nameable#
- class jangada.mixin.Nameable#
Bases:
objectMixin that adds a human-readable name.
Provides a name attribute for display and labeling purposes. Names are less restrictive than tags - they can contain spaces, special characters, and non-ASCII characters. They are intended for user-facing contexts like UI labels, reports, and logs.
Names are normalized by stripping whitespace and converting empty strings to None.
- Attributes:
- namestr or None
A human-readable name string. Can contain any characters. Leading/trailing whitespace is stripped. Empty strings become None.
See also
TaggableSymbolic identifier for namespace access
DescribableExtended description text
Notes
- Validation
Minimal validation is performed. Any value is converted to string and stripped. Empty results become None.
- Use Cases
UI labels and display text
Report headers
Log messages
User-facing identifiers
Documentation titles
- Comparison with Tag
Tags are for programmatic access (strict validation), names are for human display (loose validation). Objects often have both:
component.tag = "temp_sensor_01" # For code component.name = "Temperature Sensor #1" # For UI
- Length
No length restrictions are imposed. Very long names are allowed but may need truncation for display purposes.
Examples
Basic usage:
obj = Nameable() obj.name = "Temperature Sensor" print(obj.name) # 'Temperature Sensor'
Special characters allowed:
obj.name = "Sensor #1 (Main)" obj.name = "Test-Case-A" obj.name = "Tëst Nämé" obj.name = "测试名称"
Normalization:
obj.name = " Name " print(obj.name) # 'Name' (whitespace stripped) obj.name = " " print(obj.name) # None (empty after stripping) obj.name = "" print(obj.name) # None
Type conversion:
obj.name = 123 print(obj.name) # '123' obj.name = 3.14 print(obj.name) # '3.14'
- __init__(*args, **kwargs)#
Methods
__delattr__(name, /)Implement delattr(self, name).
__dir__(/)Default dir() implementation.
__eq__(value, /)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__getstate__(/)Helper for pickle.
__gt__(value, /)Return self>value.
__hash__(/)Return hash(self).
__init__(*args, **kwargs)__init_subclass__This method is called when a class is subclassed.
__le__(value, /)Return self<=value.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__reduce__(/)Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__(/)Return repr(self).
__sizeof__(/)Size of object in memory, in bytes.
__str__(/)Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
Attributes
__annotations__Human-readable display name.