espnet2.utils.types.str2triple_str
Less than 1 minute
espnet2.utils.types.str2triple_str
espnet2.utils.types.str2triple_str(value: str) → Tuple[str, str, str]
Converts a comma-separated string into a tuple of three strings.
This function takes a string formatted as “a,b,c” and returns a tuple containing the three components as strings. Leading and trailing spaces are removed, and any surrounding parentheses or quotes are stripped from each component.
- Parameters:value (str) – A comma-separated string to be converted into a tuple.
- Returns: A tuple containing three strings parsed from the input value.
- Return type: Tuple[str, str, str]
Examples
>>> str2triple_str('abc,def ,ghi')
('abc', 'def', 'ghi')
>>> str2triple_str('( abc, "def", ghi )')
('abc', 'def', 'ghi')
NOTE
If the input string does not contain exactly two commas, this function will raise a ValueError.