def clean_line(line, comment_only=False):
    """Remove comments and parentheses from the input line."""
    # strip comments:
    comment_begin = line.find('#')
    line = line[:comment_begin]
    line = line.replace(',', '')
    if not comment_only:
        # remove parentheses:
        line = line.replace('[', '').replace(']', '')
        line = line.replace('(', '').replace(')', '')
    return line