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
mapnaqi
V2EX  ›  Python

scrapy Middleware 里面的类算不算装饰器?

  •  
  •   mapnaqi · 2019-02-27 12:01:06 +08:00 · 1771 次点击
    这是一个创建于 1856 天前的主题,其中的信息可能已经有所发展或是发生改变。
    7 条回复    2019-03-02 19:06:41 +08:00
    warcraft1236
        1
    warcraft1236  
       2019-02-27 15:34:01 +08:00
    不算吧,我记得装饰器的形参应该是 function
    BiggerLonger
        2
    BiggerLonger  
       2019-02-27 15:36:30 +08:00
    應該是跟 Django 的 middleware 一個概念
    ipwx
        3
    ipwx  
       2019-02-27 15:37:22 +08:00
    其实没必要死扣这些概念。

    如果你想死抠,那么顾名思义,Middleware 就是 Middleware。
    besttime
        4
    besttime  
       2019-02-27 17:26:00 +08:00
    Middleware 应该是中间件,跟装饰器完全没关系的啊。
    xiayebaibi
        5
    xiayebaibi  
       2019-02-27 17:37:08 +08:00 via Android
    发现同款头像
    kidlfy
        6
    kidlfy  
       2019-03-01 15:14:48 +08:00
    你想写带装饰器的 middleware 也不是不可以 但是 middleware 不是装饰器 去看看这两词的概念就知道了
    911speedstar
        7
    911speedstar  
       2019-03-02 19:06:41 +08:00
    中间件和装饰器 两个概念
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3295 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:40 · PVG 08:40 · LAX 17:40 · JFK 20:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.