我想要做这样的事情的所有方法:遍历Python程序
def a():
# do stuff
return stuff
def b():
# do stuff
return different_stuff
def c():
# do one last thing
return 200
for func in this_file:
print func_name
print func_return_value
我基本上是想模仿这种瓶的应用程序,而无需将烧瓶部分:
app = Flask(__name__)
app.register_blueprint(my_bp, url_prefix='/test')
my_bp.data = fake_data
def tests():
with app.test_client() as c:
for rule in app.url_map.iter_rules():
if len(rule.arguments) == 0 and 'GET' in rule.methods:
resp = c.get(rule.rule)
log.debug(resp)
log.debug(resp.data)
这是可能的?
使用'callable(f)'来确定是否可以调用'f'。比照http://docs.python.org/2.7/library/functions.html#callable – bgporter
@bgporter谢谢。编辑 – Hyperboreus