import re


def _split_commands(script):
    """ Split commands from a string into a list of commands.

    Arguments
    ---------
    script: str
        Command as read directly from a file.

    Returns
    -------
    str:
        List of commands, lines with only whitespce removed,
        and also lines starting with #.
    """
    real_commands = []
    for line in script.split("\n"):
        only_whitespace = re.match(r"\A\s*\Z", line) is not None
        sw_hash = re.match(r"^#", line) is not None
        if only_whitespace or sw_hash:
            continue
        real_commands.append(line)
    return real_commands