maybe this can help (can get also lambda but it's very simple),
import linecache
def get_source(f):
    source = []
    first_line_num = f.func_code.co_firstlineno
    source_file = f.func_code.co_filename
    source.append(linecache.getline(source_file, first_line_num))
    source.append(linecache.getline(source_file, first_line_num + 1))
    i = 2
    # Here i just look until i don't find any indentation (simple processing).  
    while source[-1].startswith(' '):
        source.append(linecache.getline(source_file, first_line_num + i))
        i += 1
    return "\n".join(source[:-1])