colour.utilities.Structure#

class colour.utilities.Structure(*args: Any, **kwargs: Any)[source]#

Bases: dict

Represent a dict-like structure that enables access to key values through dot notation syntax.

This class extends the built-in dict to provide attribute-style access to dictionary items, allowing both traditional dictionary access patterns and object-oriented dot notation for improved code readability and convenience.

Parameters:
  • args (Any) – Arguments.

  • kwargs (Any) – Key / value pairs.

Methods

References

[Rak17]

Examples

>>> person = Structure(first_name="John", last_name="Doe", gender="male")
>>> person.first_name
'John'
>>> sorted(person.keys())
['first_name', 'gender', 'last_name']
>>> person["gender"]
'male'
__init__(*args: Any, **kwargs: Any) None[source]#
Parameters:
Return type:

None

__setattr__(name: str, value: Any) None[source]#

Assign the specified value to the attribute with the specified name.

Parameters:
  • name (str) – Name of the attribute to assign the value to.

  • value (Any) – Value to assign to the attribute.

Return type:

None

__delattr__(name: str) None[source]#

Delete the attribute with the specified name.

Parameters:

name (str) – Name of the attribute to delete.

Return type:

None

__dir__() Iterable[source]#

Return the list of valid attributes for the dict-like object.

Returns:

List of valid attributes for the dict-like object.

Return type:

list

__getattr__(name: str) Any[source]#

Return the value from the attribute with the specified name.

Parameters:

name (str) – Name of the attribute to get the value from.

Returns:

Value of the specified attribute.

Return type:

object

Raises:

AttributeError – If the attribute is not defined.

__setstate__(state: Any) None[source]#

Set the object state when unpickling.

Parameters:

state (Any)

Return type:

None

__weakref__#

list of weak references to the object