get a list of functions from a Python program

def get_functions(fname):
    """ get a list of functions from a Python program """
    txt = '' 
    with open(fname, 'r') as f:
        for line in f:
            if line.strip()[0:4] == 'def ':
                txt += '<PRE>' + strip_text_after_string(strip_text_after_string(line, '#')[4:], ':') + '</PRE>\n'
            if line[0:5] == 'class':
                txt += '<PRE>' + strip_text_after_string(strip_text_after_string(line, '#'), ':') + '</PRE>\n'
    return txt + '<BR>'