我想要做這樣的事情的所有方法:遍歷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