TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Introduction to Python Decorators

79 点作者 xlm超过 13 年前

5 条评论

molbioguy超过 13 年前
An excellent tutorial/answer about python decorators was posted on stack overflow:<p><a href="http://stackoverflow.com/questions/739654/understanding-python-decorators/1594484#1594484" rel="nofollow">http://stackoverflow.com/questions/739654/understanding-pyth...</a>
评论 #3022276 未加载
评论 #3022645 未加载
评论 #3022269 未加载
Goladus超过 13 年前
The only thing I'd like to see more of with respect to decorators is discussion of real benefits. The concept is fairly simple it's the technique and resulting code organization that is interesting. Much like Lisp macros, it's important to know when not to use them and none of the tutorials I've seen really address that.
评论 #3041307 未加载
cgranade超过 13 年前
The only thing that I might ever want from functional and symbolic programming paradigms that I can't imagine how to emulate with decorators would be the ability to transform the actual compiled function object in some way. Python decorators can add lots of new code, sure, but they don't get access to the syntax tree for the function object to be able to break it apart and transform it.<p>Mind you, I truly love Python decorators, but I just don't think the comparison to languages like LISP quite holds up. Maybe I'm just inexperienced, though...
评论 #3023004 未加载
famousactress超过 13 年前
Just me, or do others think any tutorial about python decorators ought to introduce and encourage the use of functools.wraps() ?
评论 #3022505 未加载
ccarpenterg超过 13 年前
A library of Python decorators: <a href="http://wiki.python.org/moin/PythonDecoratorLibrary" rel="nofollow">http://wiki.python.org/moin/PythonDecoratorLibrary</a>