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

python 之禅

  •  
  •   wccandww · 2011-01-18 18:15:57 +08:00 · 5619 次点击
    这是一个创建于 5059 天前的主题,其中的信息可能已经有所发展或是发生改变。
    followers_count
    3 条回复    1970-01-01 08:00:00 +08:00
    wccandww
        1
    wccandww  
    OP
       2011-01-18 18:17:09 +08:00
    import this
    >>>
    The Zen of Python, by Tim Peters

    Beautiful is better than ugly.
    漂亮的代码要比丑陋的代码要好得多。
    Explicit is better than implicit.
    明确的定义比 隐式定义更好。
    Simple is better than complex.
    简单比负责要好。
    Complex is better than complicated.
    负责要比搞复杂要好。
    Flat is better than nested.
    扁平结构要比嵌套结构好。
    Sparse is better than dense.
    简洁明了的代码要比稠密的代码要好。
    Readability counts.
    可读写的计数。
    Special cases aren't special enough to break the rules.
    专门的用例不是特殊到足以违反规则。
    Although practicality beats purity.
    是的,实用性练就纯度。
    Errors should never pass silently.
    错误永远都不会沉默。
    Unless explicitly silenced.
    除非明确啥也不干。
    In the face of ambiguity, refuse the temptation to guess.
    面对模糊定义、拒绝视图拍脑袋猜。
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    虽然一开始不那面明确,我们会选择更清晰一条到走。
    Now is better than never.
    现在开始总比不开始的要好。
    Although never is often better than *right* now.
    虽然从不尝试总比现在开始尝试好。
    If the implementation is hard to explain, it's a bad idea.
    如果实现难以说明,那它是个坏主意。
    If the implementation is easy to explain, it may be a good idea.
    如果实现容易说明,那它是个好主意。
    Namespaces are one honking great idea -- let's do more of those!
    名称空间是一个好东西——让我们做更多那样的东西!



    Don't reinvent the wheel

    Before writing any code,
    ➔ ➔ ➔ ➔
    Check Python's standard library.

    Check the Python Package Index (the "Cheese Shop"):

    http://cheeseshop.python.org/pypi

    Search the web. Google is your friend.



    python 八荣八耻
    以动手实践为荣 , 以只看不练为耻;
    以打印日志为荣 , 以单步跟踪为耻;
    以空格缩进为荣 , 以制表缩进为耻;
    以单元测试为荣 , 以人工测试为耻;

    以模块复用为荣 , 以复制粘贴为耻;
    以多态应用为荣 , 以分支判断为耻;
    以Pythonic为荣 , 以冗余拖沓为耻;
    以总结分享为荣 , 以X求其解为耻;
    dongbeta
        2
    dongbeta  
       2011-01-18 18:24:56 +08:00
    翻译得不好
    pennyg
        3
    pennyg  
       2011-01-18 21:15:46 +08:00
    readability counts翻译错了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4924 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 04:00 · PVG 12:00 · LAX 20:00 · JFK 23:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.