1. 程式人生 > >細數10個隱藏在Python中的彩蛋

細數10個隱藏在Python中的彩蛋

>>> 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 way 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! 名稱空間是個絕妙的想法,讓我們多多地使用它們吧!