{"id":710,"date":"2022-06-04T08:17:33","date_gmt":"2022-06-04T08:17:33","guid":{"rendered":"https:\/\/blog.liuyingjie.com.cn\/?p=710"},"modified":"2023-01-29T08:27:34","modified_gmt":"2023-01-29T08:27:34","slug":"zen-of-python","status":"publish","type":"post","link":"https:\/\/blog.liuyingjie.com.cn\/?p=710","title":{"rendered":"Zen of Python"},"content":{"rendered":"\n<p>The&nbsp;<strong>Zen of Python<\/strong>&nbsp;is a collection of 19 &#8220;guiding principles&#8221; for writing&nbsp;computer programs&nbsp;that influence the design of the&nbsp;Python&nbsp;programming language.&nbsp;Software engineer&nbsp;Tim Peters&nbsp;wrote this set of principles and posted it on the Python mailing list in 1999.&nbsp;Peters&#8217;s list left open a 20th principle &#8220;for Guido to fill in&#8221;, referring to&nbsp;Guido van Rossum, the original author of the Python language. The vacancy for a 20th principle has not been filled.<\/p>\n\n\n\n<p>Peters&#8217;s Zen of Python was included as entry number 20 in the language&#8217;s official&nbsp;Python Enhancement Proposals&nbsp;and was released into the&nbsp;public domain.&nbsp;It is also included as an&nbsp;Easter egg&nbsp;in the Python&nbsp;interpreter, where it can be displayed by entering&nbsp;<code><strong>import<\/strong>&nbsp;<strong>this<\/strong><\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Principles<\/h2>\n\n\n\n<p>The principles are listed as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Beautiful is better than ugly.<\/li>\n\n\n\n<li>Explicit is better than implicit.<\/li>\n\n\n\n<li>Simple is better than complex.<\/li>\n\n\n\n<li>Complex is better than complicated.<\/li>\n\n\n\n<li>Flat is better than nested.<\/li>\n\n\n\n<li>Sparse is better than dense.<\/li>\n\n\n\n<li>Readability counts.<\/li>\n\n\n\n<li>Special cases aren&#8217;t special enough to break the rules.<\/li>\n\n\n\n<li>Although practicality beats purity.<\/li>\n\n\n\n<li>Errors should never pass silently.<\/li>\n\n\n\n<li>Unless explicitly silenced.<\/li>\n\n\n\n<li>In the face of ambiguity, refuse the temptation to guess.<\/li>\n\n\n\n<li>There should be one\u2013 and preferably only one \u2013obvious way to do it.<\/li>\n\n\n\n<li>Although that way may not be obvious at first unless you&#8217;re Dutch.<\/li>\n\n\n\n<li>Now is better than never.<\/li>\n\n\n\n<li>Although never is often better than&nbsp;<em>right<\/em>&nbsp;now.<\/li>\n\n\n\n<li>If the implementation is hard to explain, it&#8217;s a bad idea.<\/li>\n\n\n\n<li>If the implementation is easy to explain, it may be a good idea.<\/li>\n\n\n\n<li>Namespaces are one honking great idea&nbsp;\u2013 let&#8217;s do more of those!<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The&nbsp;Zen of Python&nbsp;is a collection of 19 &#038;#822 &hellip; <a href=\"https:\/\/blog.liuyingjie.com.cn\/?p=710\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Zen of Python<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-710","post","type-post","status-publish","format-standard","hentry","category-python3"],"_links":{"self":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=710"}],"version-history":[{"count":4,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions\/858"}],"wp:attachment":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}