推荐学习书目
› 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
ryanking8215
V2EX  ›  Python

python 的 lambda 不是可以实现偏函数, functools.partial 的意义呢?

  •  1
     
  •   ryanking8215 ·
    ryanking8215 · Mar 25, 2016 · 3903 views
    This topic created in 3845 days ago, the information mentioned may be changed or developed.
    我是不是漏掉了什么?
    4 replies  •  2016-03-25 21:11:19 +08:00
    Ge4Los
        1
    Ge4Los  
       Mar 25, 2016   ❤️ 2
    显式,更表义。
    既然列表生成式可以实现 filter 功能,为何要用? filter 更表义。
    tabris17
        2
    tabris17  
       Mar 25, 2016   ❤️ 1
    偏函数就是柯里化吧,用 functools.partial 实现柯里化可以少些几行代码
    hahastudio
        3
    hahastudio  
       Mar 25, 2016   ❤️ 1
    lambda 是 Currying 吧, functools.partial 才是偏函数吧?
    比如你想固定 foo(a, b) 里面的 a 抑或 b ,你用 lambda 大概得需要两个吧 fooa(b) 和 foob(a)。如果你不需要两个,基本上你就是接近于实现了一个 functools.partial
    billgreen1
        4
    billgreen1  
       Mar 25, 2016   ❤️ 3
    lambda functions can not be pickled
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:18 · PVG 02:18 · LAX 11:18 · JFK 14:18
    ♥ Do have faith in what you're doing.