to_int_list¶
- sofia_redux.scan.utilities.utils.to_int_list(values, is_positive=True)[source]¶
Convert all elements in a list to integers.
String representations of integers may also be included as ranges. The default behaviour is to treat the ‘-’ character as range rather than a minus sign. Ranges should generally be specified using the ‘:’ character. To allow negative values, set
is_positive=False
.For example >>> print(to_int_list([‘1-3’])) [1, 2, 3] >>> print(to_int_list([‘-1:3’], is_positive=False)) [-1, 0, 1, 2, 3]
If is_positive is not set, the meaning of ‘-’ is ambiguous and can result in errors.
- Parameters:
- valueslist
- is_positivebool, optional
If
True
, ranges may be specified using both ‘:’ and ‘-’ characters in a string. Otherwise, the ‘-’ character will imply a negative value.
- Returns:
- list (int)