"""Hi, how can I extend the code shown below so that I can identify
any "CallFunc" in "func.code" and identify the value of "node" in
"CallFunc"? Thanks.

This is my code so far:
"""

""" Given a python file, this program prints out each function's name
in that file, the line number and the ast code of that function.

"""

import compiler
import compiler.ast

parse_file = compiler.parseFile("/home/glich/file.py")

count = 0

while count < (len(parse_file.node.nodes) - 1):

        func = parse_file.node.nodes[count]

        print "\nFunc name: " + str(func.name)
        print "Func line number: " + str(func.lineno) + "\n"

        print str(func.code) + "\n"

        count += 1


"""file.py:


def fun1():

    print "Hi"
    hi = "1"

    fun2()
    fun4()

def fun2():

    fun3()

def fun3():

    fun4()

def fun4():
    print "Hi"

fun1()

"""

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to