rstoolbox.components.Selection.to_list

Selection.to_list(length=None)

Provide the values of the Selection as a list of integers.

Parameters:

length (int) – Expected total length of the sequence to which the Selection will be applied.

Returns:

(list() of int) – Numerical list representation of the selection positions.

Raises:
AttributeError:If the Selection is reversed and no length is provided.

If the Selection is reversed, the length over which it will be applied needs to be provided, so that the actual selected positions can be determined.

In [1]: sr = ~ss
   ...: ss.to_list(25)
   ...: 
Out[1]: [3, 4, 5, 13, 14, 15, 21, 25]

Example

In [2]: from rstoolbox.components import Selection
   ...: ss = Selection("3-5,13-15,21,25")
   ...: ss.to_list()
   ...: 
Out[2]: [3, 4, 5, 13, 14, 15, 21, 25]