colour.utilities.Lookup

class colour.utilities.Lookup[source]

Bases: dict

Extend dict type to provide a lookup by value(s).

Methods

References

[Mana]

Examples

>>> person = Lookup(first_name='John', last_name='Doe', gender='male')
>>> person.first_key_from_value('John')
'first_name'
>>> persons = Lookup(John='Doe', Jane='Doe', Luke='Skywalker')
>>> sorted(persons.keys_from_value('Doe'))
['Jane', 'John']
keys_from_value(value: Any) List[source]

Get the keys associated with given value.

Parameters

value (Any) – Value to find the associated keys.

Returns

Keys associated with given value.

Return type

list

first_key_from_value(value: Any) Any[source]

Get the first key associated with given value.

Parameters

value (Any) – Value to find the associated first key.

Returns

First key associated with given value.

Return type

object

__weakref__

list of weak references to the object (if defined)