2007年04月01日 星期日 13:15
On 3/30/07, Ren Zhen <fblist at gmail.com> wrote: > > 初学python,看django的代码 > 在transaction.py里面看到有 > def commit_manually(func): > def _commit_manually(*args, **kw): > try: > enter_transaction_management() > managed(True) > return func(*args, **kw) > finally: > leave_transaction_management() > > return _commit_manually > > 这种形式的写法。在用的时候写的是 > > @transaction.commit_manually > > 不知这是什么用法。有@在网上似乎也不好搜:( > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > @ 就是个简单的语法糖, @transaction.commit_manually def temp():pass 等价于: def temp():pass temp = transaction.commit_manually(temp) -- http://codeplayer.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070401/17c6b1b9/attachment.htm
Zeuux © 2025
京ICP备05028076号