aboutsummaryrefslogtreecommitdiff
blob: 96a7c819a19db9cdec774e15c6e325e7cbf49244 (plain)
1
2
3
4
5
6
7
8
9
10
11
"""String processing utilities"""
def pivot(string, idx, keep_pivot=True):
    """
    A function to split a string in two, pivoting at string[idx].
    If keep_pivot is set, the pivot character is included in the second string.
    Alternatively, it is omitted.
    """
    if keep_pivot:
        return (string[:idx], string[idx:])
    else:
        return (string[:idx], string[idx+1:])