V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  tongjie  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2016-08-08 22:49:09 +08:00
回复了 SlipStupig 创建的主题 Python 想请教一下 python 装饰器的作用
def safe_run(_logger):
def _run_once(func):
def f(*args,**kwargs):
try:
return func(*args,**kwargs)
except:
_logger.error(traceback.format_exc())
return f
return _run_once

在要执行的方法前面加上这个装饰器,放心多了;
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   910 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 21:09 · PVG 05:09 · LAX 14:09 · JFK 17:09
Developed with CodeLauncher
♥ Do have faith in what you're doing.