V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
jianghu52
V2EX  ›  Python

python 新人求教关于装饰器的问题。

  •  2
     
  •   jianghu52 · 2014-06-10 08:56:52 +08:00 · 3049 次点击
    这是一个创建于 3607 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想知道在有参数的装饰器装饰有参数的函数的时候,编译器是怎么一个执行顺序
    5 条回复    2014-06-10 14:54:23 +08:00
    tonghuashuai
        1
    tonghuashuai  
       2014-06-10 09:51:21 +08:00   ❤️ 2
    ultimate010
        2
    ultimate010  
       2014-06-10 11:17:40 +08:00
    学习了。
    jianghu52
        3
    jianghu52  
    OP
       2014-06-10 11:47:46 +08:00
    谢谢。说好的很明白
    poke707
        4
    poke707  
       2014-06-10 13:33:45 +08:00
    我理解的"@"是一个语法糖,定义funciton时用@foo修饰,相当于定义完后再写function=foo(function)
    至于@foo带参数,相当于function=foo(*arg)(function)
    yueyoum
        5
    yueyoum  
       2014-06-10 14:54:23 +08:00 via Android
    @poke707

    需要理解吗? 文档里写的一清二楚啊
    就是这个
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5297 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:04 · PVG 16:04 · LAX 01:04 · JFK 04:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.