import ast
from collections import namedtuple
import sys


def find_method_lengths(code):
    tree = ast.parse(code)
    return [Method(node.name, length(node)) for node in ast.walk(tree) if
            isinstance(node, ast.FunctionDef)]


def length(node):
    return last_line(node) - node.lineno - docstring_length(node)


def docstring_length(node):
    docstring = ast.get_docstring(node, clean=False)
    return 0 if docstring is None else docstring.count('\n') + 1


def last_line(node, highest=0):
    if get_line_no(node) > highest:
        highest = get_line_no(node)
    children = ast.iter_child_nodes(node)
    child_lines = map(last_line, children)
    return max([get_line_no(node)] + child_lines)


def get_line_no(node):
    return getattr(node, 'lineno', float('-inf'))


Method = namedtuple('Method', 'name lines')


if __name__ == '__main__':
    code = '\n'.join(open(arg).read() for arg in sys.argv[1:])
    methods = find_method_lengths(code)
    for method in methods:
        print '%s\t%s' % (method.lines, method.name)

import ast
from collections import namedtuple
import sys


def find_method_lengths(code):
    tree = ast.parse(code)
    return [Method(node.name, length(node)) for node in ast.walk(tree) if
            isinstance(node, ast.FunctionDef)]


def length(node):
    return last_line(node) - node.lineno - docstring_length(node)


def docstring_length(node):
    docstring = ast.get_docstring(node, clean=False)
    return 0 if docstring is None else docstring.count('\n') + 1


def last_line(node):
    children = ast.iter_child_nodes(node)
    child_lines = map(last_line, children)
    return max([get_line_no(node)] + child_lines)


def get_line_no(node):
    return getattr(node, 'lineno', float('-inf'))


Method = namedtuple('Method', 'name lines')


if __name__ == '__main__':
    code = '\n'.join(open(arg).read() for arg in sys.argv[1:])
    methods = find_method_lengths(code)
    for method in methods:
        print '%s\t%s' % (method.lines, method.name)

remove dead code.