Zen of Python:python

Source: Internet
Author: User

Recently in Python, I saw a blog about Python, called "The Python Full Stack Road series," which begins with Python's philosophy of Design: elegant, concise, efficient ...

You can enter the following statement in the compiler to see the design philosophy of the Python language:

1>>>Import This2 the Zen of Python, by Tim Peters3 4Beautiful isbetter than ugly.5Explicit isbetter than implicit.6Simple isbetter than complex.7Complex isbetter than complicated.8Flat isbetter than nested.9Sparse isbetter than dense.Ten readability counts. OneSpecial cases aren'T special enough to break the rules. A Although practicality beats purity. -Errors should neverPasssilently. - unless explicitly silenced. the in the face of ambiguity, refuse the temptation to guess. -There should be one-- andPreferably only one--obvious-do it. -Although that, may notBe obvious at first unless're Dutch. -Now isbetter than never. +Although never isOften better than *right*Now . -If the implementation isHard to explain, it's a bad idea. +If the implementation isEasy to explain, it is a good idea. ANamespaces is one honking great idea – let's do more than those!

The Chinese and English interpretations are as follows:

1Beautiful isbetter than ugly.2 #beauty is better than ugliness (Python aims to write graceful code)3Explicit isbetter than implicit.4 #clarity is better than obscure (graceful code should be clear, naming specification, style similar)5Simple isbetter than complex.6 #simplicity is better than complexity (graceful code should be concise, not complex internal implementations)7Complex isbetter than complicated.8 #complexity is better than clutter (if complexity is unavoidable, there is no hard-to-understand relationship between the code, keep the interface simple)9Flat isbetter than nested.Ten #flattening is better than nesting (graceful code should be flat, not too much nesting) OneSparse isbetter than dense. A #The interval is better than the compact (graceful code has the appropriate interval, do not expect a line of code to solve the problem) - readability counts. - #readability is important (graceful code is readable) theSpecial cases aren'T special enough to break the rules. - Although practicality beats purity. - #even in the name of the practicality of the special case, the rules must not be violated (these rules are paramount) -Errors should neverPasssilently. + unless explicitly silenced. - #do not tolerate all errors unless you are sure you need to (catch exceptions accurately, do not write Except:pass-style code) + in the face of ambiguity, refuse the temptation to guess. A #when there are many possibilities, don't try to guess atThere should be one-- andPreferably only one--obvious-do it. - #instead, try to find one, preferably the only obvious solution (if unsure, use the brute-lifting method) -Although that, may notBe obvious at first unless're Dutch. - #Although this is not easy, because you are not the father of Python (here Dutch refers to Guido) -Now isbetter than never. -Although never isOften better than *right*Now . in #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 isHard to explain, it's a bad idea. toIf the implementation isEasy to explain, it is 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! the #namespaces are a great idea and we should use them (advocacy and calling).

Then I tried the demo code inside:

1 # coding = Utf-8 2 Print ("" "3My name is Zhangweigong4My blogs URL is:www.cnblogs.com/imyalost 5 Life are so short,i need python 6 """)

The results of the operation can be successfully run, but the printed results in front, specifically mentioned in Python's design philosophy, that the code is not concise and efficient ...

Suddenly understand a truth: learn a programming language, you must understand the characteristics of the language ...

Actually do one thing to learn a technology is also the same (not limited to programming language, although the programming language is also a technology, means), to understand its specific, to better use it, play its role!!!

Warning, young man ...

Zen of Python: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.