python之禅
今天看了传说中的Zen of Python(Python之禅)。。。太有哲理了😄。
我试着用自己的言语翻译一下:
- 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.
尽管这个明显的答案一开始并不明显,除非你是那个荷兰人。(python语言的作者是荷兰人)
- 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!
命名空间是个很棒的思路,我们要多多使用它。
</br>
留下评论