import time
import datetime
pool=[] # to avoid loops
def recdir(d,n=''):
children_all=dir(d)
children=[c for c in children_all if c[0]!='_' and not c in pool]
for child in children:
pool.append(child)
full_name=n+"."+child
print "Found: ","'"+full_name+"' type=",eval("type("+full_name+")")
string="recdir(d."+child+",'"+full_name+"')"
print "Evaluating :",string
time.sleep(0.2)
eval(string)
recdir(datetime,'datetime')
这段代码递归地列出模块的内容。但是请注意,如果两个子模块/对象/。。。同名
相关问题 更多 >
编程相关推荐