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

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

  •  1
     
  •   ryanking8215 ·
    ryanking8215 · 2016-03-25 14:47:28 +08:00 · 2989 次点击
    这是一个创建于 2945 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我是不是漏掉了什么?
    4 条回复    2016-03-25 21:11:19 +08:00
    Ge4Los
        1
    Ge4Los  
       2016-03-25 14:57:53 +08:00   ❤️ 2
    显式,更表义。
    既然列表生成式可以实现 filter 功能,为何要用? filter 更表义。
    tabris17
        2
    tabris17  
       2016-03-25 15:09:40 +08:00   ❤️ 1
    偏函数就是柯里化吧,用 functools.partial 实现柯里化可以少些几行代码
    hahastudio
        3
    hahastudio  
       2016-03-25 15:15:16 +08:00   ❤️ 1
    lambda 是 Currying 吧, functools.partial 才是偏函数吧?
    比如你想固定 foo(a, b) 里面的 a 抑或 b ,你用 lambda 大概得需要两个吧 fooa(b) 和 foob(a)。如果你不需要两个,基本上你就是接近于实现了一个 functools.partial
    billgreen1
        4
    billgreen1  
       2016-03-25 21:11:19 +08:00   ❤️ 3
    lambda functions can not be pickled
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5985 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:32 · PVG 10:32 · LAX 19:32 · JFK 22:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.