inpystem.tools.misc module¶
This module defines some miscellaneous functions.
-
inpystem.tools.misc.
toslice
(text=None, length=None)¶ Parses a string into a slice.
Input strings can be eg. ‘5:10’, ‘:10’, ‘1:’. Negative limits are allowed only if the data length is given. In such case, input strings can be e.g. ‘1:-10’. Last, an integer can be given alone such as ‘1’ to select only the 1st element.
If no text not length is given, default slice is slice(None).
- Parameters
text (optional, None, str) – The input text to parse. Default is None.
length (None, int) – The data length. This is not mendatory if no slice limit is negative. Dafault is None.
- Returns
The parsed slice object.
- Return type
slice