openmnglab.util.iterables.ensure_sequence#
- openmnglab.util.iterables.ensure_sequence(inp: ~typing.Iterable[~openmnglab.util.iterables.T] | ~openmnglab.util.iterables.T | None, type: ~typing.Type[~openmnglab.util.iterables.T], sequence_constructor: ~typing.Callable[[~typing.Iterable[~openmnglab.util.iterables.T]], ~typing.Sequence[~openmnglab.util.iterables.T]] = <class 'tuple'>) Sequence[T][source]#
Ensures that the input is a sequence.
See also
ensure_iterable()for a varaint of this function which will return an interableSee also
unpack_sequence()for the inverse operationRun checks:
inpisNone: returns an empty tupleinpis an instace oftype: returns a tuple withinpas sole elementinpimplements typeSequence: returninpwithout modificationAttempts to convert
inpto aSequenceby invokingsequence_constructor
- Parameters:
inp – Value to convert to a sequence
type – Type of the value(s) passed to
inpsequence_constructor – Callable used to convert
inpto aSequence, defaults totuple.
- Returns:
A sequence of values