Skip to content

Splits

Split = Parse[List[str]] module-attribute

Represents split functions.

split_lines = split_at(NEW_LINE) module-attribute

Splits the string by NEW_LINE.

split_double_lines = split_at(DOUBLE_NEW_LINE) module-attribute

Splits the string by DOUBLE_NEW_LINE.

split_at(separator: str) -> Split

Creates split functions that split the string by separator.

Parameters:

Name Type Description Default
separator str

The separator to split the string by.

required

Returns:

Type Description
Split

The split function created.

Source code in aoc/ext/splits.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def split_at(separator: str) -> Split:
    """Creates `split` functions that split the `string` by `separator`.

    Arguments:
        separator: The separator to split the string by.

    Returns:
        The `split` function created.
    """

    def split(string: str) -> List[str]:
        return string.split(separator)

    return split

split_whitespace(string: str) -> List[str]

Splits the string by whitespace.

This is equivalent to:

string.split()

Parameters:

Name Type Description Default
string str

The string to split.

required

Returns:

Type Description
List[str]

The split result.

Source code in aoc/ext/splits.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def split_whitespace(string: str) -> List[str]:
    """Splits the `string` by whitespace.

    This is equivalent to:

    ```python
    string.split()
    ```

    Arguments:
        string: The string to split.

    Returns:
        The split result.
    """
    return string.split()