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

看到一篇写 python 元类的 感觉写得太好了 情不自禁想分享给大家

  •  1
     
  •   geew · Nov 3, 2014 · 5198 views
    This topic created in 4346 days ago, the information mentioned may be changed or developed.
    8 replies  •  2014-11-14 00:46:15 +08:00
    limbo0
        1
    limbo0  
       Nov 3, 2014
    只能看懂中文,好东西,赞
    mywaiting
        2
    mywaiting  
       Nov 3, 2014
    metaclass 感觉都被妖魔化了,成为大家心中黑科技的代表了。可这个概念的理解那有这么艰难。

    简单点说,metaclass就是妈妈,生下了class这个儿子,class实例化后就是instance

    metaclass遍地用于各种ORM,随便翻翻各种Python ORM的代码就可以理解了~
    ashamp
        3
    ashamp  
       Nov 3, 2014
    既然你说的这么好,我就标记一下吧
    sujunj2005
        4
    sujunj2005  
       Nov 3, 2014
    感觉真的是黑科技的代表……
    lushl9301
        5
    lushl9301  
       Nov 3, 2014
    哈哈。。。stackoverflow上面被改成python3的格式了哈哈哈。。。
    messense
        6
    messense  
       Nov 3, 2014
    metaclass 和 descriptor 都是很好用的东西。
    dogfeet
        7
    dogfeet  
       Nov 4, 2014
    不就是模板类的思路嘛。任何语言没这个特性表述能力都要下降不少吧。
    2owe
        8
    2owe  
       Nov 14, 2014
    1. 新技能get,对 type 有了新认识。
    2. 看着原作者由浅入深,环环相扣的讲解,着实感动。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   818 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 20:01 · PVG 04:01 · LAX 13:01 · JFK 16:01
    ♥ Do have faith in what you're doing.