The Zen of Python

Source: Internet
Author: User

In the module section of the Blogger learning Python, I accidentally wrote this sentence:

Import this

Causes the following to occur:

Original and translation:

The Zen of Python, by Tim Petersbeautiful is better than ugly.# graceful than ugly (Python to write beautiful code for the goal) Explicit is better than implicit. # clarity is better than obscure (beautiful code should be clear, naming specification, style similar) simple is better than complex.# simplicity is better than complexity (graceful code should be concise, not complicated) complex is better than complicated.# complexity is better than messy (if the complexity is unavoidable, the code can not have a difficult relationship, to keep the interface concise) Flat is better than nested.# flat better than nesting (graceful code should be flat, not too much nesting) Sparse is better than dense.# interval is better than compact (graceful code has the appropriate interval, do not expect a line of code to solve the problem) readability counts.# readability is important (beautiful code is readable) special cases aren ' t Special enough to break the rules. Although practicality beats purity.# even in the name of the practicality of the special case, it must not violate these rules (these rules are paramount) Errors should never pass silently. Unless explicitly silenced.# do not tolerate all errors unless you are sure you need to do this (accurately capturing exceptions, not writing Except:pass-style code) in the face of ambiguity, refuse the Temptat Ion to guess.# when there are multiple possibilities, don't try to guess there should be one–and preferably just one–obvious way to do it.# instead try to find one, preferably the only obvious solution (  If you are unsure, use the exhaustive method) although that is obvious at the first unless you ' re dutch# although this is not easy because you are not the father of Python (Dutch here means Guido) now is better than never. AlthougH never is often better than *right* now.# it might be better not to do it, but it's better not to do it without thinking about it (before you do it) If the implementation is hard to explain, it's a Bad idea. If the implementation is easy to explain, it can be a good idea.# if you can't describe your plan to someone, it's certainly not a good plan; and vice versa (Program evaluation criteria) namespaces is one Honking great Idea-let's does more the those!# namespace is a wonderful idea that we should use (advocacy and call)

Zen of Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.