The Zen of Python

Source: Internet
Author: User

>>> 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 is one--and preferably only one--obvious the-do it.
Although that is obvious at first unless you ' re Dutch. The
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 an easy-to-explain, it may good idea.
Namespaces is one honking great idea – let's do more than those!

Reference translation results: https://www.cnblogs.com/imyalost/p/7414264.html

Beautiful is better than ugly.
# Beauty is better than ugliness (Python aims to write beautiful code)
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 (beautiful code should be concise, don't have complex internal implementations)
Complex is better than complicated.
# complexity is better than clutter (if complexity is unavoidable, there's no hard-to-understand relationship between the code, keep the interface simple)
Flat is better than nested.
# Flat is 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, don't expect a line of code to solve the problem)
Readability counts.
# readability is important (graceful code is readable)
Special cases aren ' t special enough to break the rules.
Although practicality beats purity.
# do not violate these rules (these rules are paramount), even in the name of the practicality of the special case.
Errors should never pass silently.
Unless explicitly silenced.
# don't tolerate all errors unless you're sure you need to (catch exceptions accurately, don't write except:pass-style code)
In the face of ambiguity, refuse the temptation to guess.
# when there are many possibilities, don't try to guess
There should is one--and preferably only one--obvious the-do it.
# but try to find one, preferably the only obvious solution (if unsure, use the brute-lifting method)
Although that is obvious at first unless you ' re Dutch.
# Although this is not easy, because you are not the father of Python (here Dutch refers to Guido)
Now is better than never.
Although never is often better than *right* now.
# It may 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 could 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 do more than those!
# Namespaces are a great idea and we should use them (advocacy and call)

The Zen of Python

Related Article

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.