colour.utilities.optional#

colour.utilities.optional(value: Optional[T], default: T) T[source]#

Handle optional argument value by providing a default value.

Parameters:
  • value (Optional[T]) – Optional argument value.

  • default (T) – Default argument value if value is None.

Returns:

Argument value.

Return type:

T

Examples

>>> optional('Foo', 'Bar')
'Foo'
>>> optional(None, 'Bar')
'Bar'