我想我想要一个装饰关键字(或等效的),*之前* 定义以避免遮蔽问题,以及 某种清楚显示订单的强制性清单。 有点像,但不一定完全相同,这个: 来自__future__进口装饰 装饰[ foo, 吧, bletch(垃圾邮件='''baz'') ] def func():... 唯一的问题是它仍有缺点@其中 装饰似乎没有绑定对函数def非常好 ,特别是如果允许空行等等。 我不清楚我认为最好的......但是然后我不介意 当前的方法很多,你只需要在整个功能块之后粘贴 的东西,那么谁在乎我的 意见? ;-) -Peter Good post, Steven, and I agree with all your own opinions on thematter as expressed above. Note one addition item that most of us are glossing over in thedebate for/against the pie (@) syntax. Order of operation. @ syntax has reversed order from the list-after-def. I thinkthe order should be readily apparent from the syntax, and Ithink the list syntax does provide that benefit over the @ syntax. I think I''d like a "decorate" keyword (or equivalent), *before*the definition to avoid the problems with obscuration, and amandatory list of some kind that clearly shows the order. Something like, but not necessarily exactly the same as, this: from __future__ import decoration decorate [foo,bar,bletch(spam=''baz'')]def func(): ... The only problem is that it still has the defect of @ whereinthe decorate doesn''t seem to "bind" to the function def verywell, especially if blank lines are allowed etc. I''m unclear on what I think it best... but then I don''t mindthe current approach much at all, where you just stick thestuff after the entire function block, so who cares about myopinion? ;-) -Peter 一个很棒的清单!如果你不介意,我可能会为PEP窃取这种格式。 它允许在更小的空间内覆盖更多的替代品 (从那以后许多提案都是对现有提案的微小变化,并且 共享相同的问题。) An excellent list! If you don''t mind, I might steal this format for the PEP.It allows for a lot more alternatives to be covered off in a smaller space(since many proposals are minor variations on an existing proposal, andshare the same problems). 请随意 - 很高兴它有用。 =)非常感谢所有 你的作品已经! 史蒂夫 - 如果你只是动词,你可以将任何字面化。 - Bucky Katt,模糊 Please feel free to -- glad it was helpful. =) Thanks so much for allyour work already! Steve --You can wordify anything if you just verb it.- Bucky Katt, Get Fuzzy 这篇关于装饰器语法建议的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 09:23