This is the first day of my participation in the More text Challenge. For details, see more text Challenge


Life is too short

Life is short, I use Python — Life is short, you need Python


The origin of Python

The founder of Python was Guido van Rossum.


  1. 1989During the Christmas season of 2000,Guido Van RossumTo pass the time in Amsterdam, determined to develop a newinterpreterAs aABCAn inheritance of language (The cow is not the same, always want to build language interpretation program)
  2. ABCIt’s a language of instruction that Guido helped design, and from Guido’s point of view, ABC is a beautiful and powerful language, yesDesigned specifically for non-professional programmers. But ABC did not succeed, and guido thinks that is whyThe open. Guido was determined to avoid this error in Python, and to great effect
  3. The reason whyPython (Python)It’s the name of the program because it’sBBCMonty Python’s Flying Circus
  4. 1991Year oneThe Python interpreterBorn, it is usedC language, and can call C language library files


The interpreter

The computer cannot directly understand any language other than machine language (0, 1), so the programming language written by the programmer must be translated into machine language before the computer can execute the program. A tool that translates other languages into machine language is called a compiler

There are two ways for a compiler to translate: one is to compile and the other is to interpret. The difference between the two approaches lies in the difference in translation time. When a compiler runs in interpreted mode, it is also called an interpreter


  • Compiled language: Before the program is executed, a special compilation process is required to compile the program into a machine language file. When the program is run, it does not need to be re-translated. The compiled results are used directly. The program execution efficiency is high, the compiler is dependent, the cross-platform is poor. Such as C, C + +
  • Interpreted languages: Programs written in interpreted languages are not precompiled. They store program code as text and run it sentence by sentence. When the program is released, it seems to save compilation, but when the program is run, it must be interpreted before it is run


Compiled languages versus interpreted languages

  • Speed – Compiled languages execute faster than interpreted languages
  • Cross-platform – Interpreted languages are more cross-platform than compiled languages


The Python interpreter is now available in several languages, including:

  • CPython— Official version of the C language implementation
  • JPython— can run on the Java platform
  • IronPython– Can run on.NET and Mono platforms
  • PyPy— Implemented in Python, supports JIT just-in-time compilation


Design goals for Python

In 1999, Guido Vanrosum submitted a grant to DARPA called “Computer Programming for Everybody,” and later explained his design goals for Python:

  • A language that is simple and intuitive and as powerful as a trendsetting language
  • Open source so that anyone can contribute to it
  • The code is as easy to understand as plain English
  • Suitable for daily tasks of short-term development

Most of these ideas have come true, and Python has become a popular programming language


Python’s design philosophy

Python’s design philosophy — elegant, simple, philosophical.


Run import this inside the Python interpreter to get the complete Python design philosophy, The Zen of Python

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 may not be obvious at first unless you're Dutch.
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!
Copy the code


Translate the following

Zen of Python by Tim Peters

Beautiful beautiful is better than ugly (Python to write the code for the target) and clear than obscure (beautiful code should be clear, naming conventions, style similar) concise than complex (beautiful code should be concise, do not have complex internal implementation) complex is better than a messy (complex is inevitable, if don’t have to understand relationship between the code, Keep your interface simple) flat rather than nested (nice code should be flat, not too much nesting) spaced rather than compact (nice code should be properly spaced, don’t expect one line of code to solve the problem) Readability is important (nice code should be readable) even in the name of special case practicability, Nor violate these rules (these rules are supreme)

Do not include all errors unless you are sure you need to (catch exceptions precisely, do not write except:pass style code)

When there are multiple possibilities, don’t try to guess but try to find one, preferably the only obvious solution (if in doubt, use exhaustive method), although this isn’t easy because you’re not the father of Python.

Doing may be better than not doing, but doing without thinking is better than not doing at all (think before you do)

If you can’t describe your plan to someone, it’s not a good plan. And vice versa (Scheme evaluation criteria)

Namespaces are a wonderful idea that we should make more use of.


The philosophy of Python developers is that there is one way, and preferably only one way, to do one thing

Given multiple options, Python developers will generally reject fancy syntax in favor of explicit syntax with little or no ambiguity


Give you reasons to choose Python

Code quantity is small, third party library is many, one of artificial intelligence preferred language…… In general, Python is 1/5 of The size of Java. If you look at the size of the father of each language, you know life is short. I use Python.


3. Python features

  • Python isA fully object-oriented language
    • Functions, modules, numbers, strings, classes are all objects. In Python, everything is an object
    • Full support for inheritance, overloading, and multiple inheritance
    • Overloaded operators are supported, and generic designs are also supported
  • Python has a powerful standard library. The core of the Python language contains only the common types and functions such as numbers, strings, lists, dictionaries, and files. The Python standard library provides additional functions such as system administration, network communication, text processing, database interface, graphics system, XML processing, and so on
  • The Python community provides a number of third-party modules that are used in a similar way to the standard library. Their functions cover scientific computing, artificial intelligence, machine learning, Web development, database interfaces, graphics systems and other fields


Object-oriented way of thinking

  • Object – oriented is a way of thinking, but also a programming technology
  • Before you solve a problem, consider firstBy whomLet’s do it. How do you do thingswhoAnd finally get things done!
    • Who is the object?
  • To solve complex problems, you can find a number of different objects, each doing its job, together to achieve, and finally complete the requirements


4. Advantages and disadvantages of Python

advantages

  • The grammar is simple and easy to learn
  • Free, open source
  • object-oriented
  • Have a rich library
  • High scalability


disadvantages

  • It’s slower than a compiled language
  • The domestic market is small
  • Lack of Chinese data


The tail language

✍ Code is used to write the world and make life more interesting. ❤ ️

✍ the long march is always love, like to go. ❤ ️

✍ code word is not easy, but also hope that you support a lot of heroes. ❤ ️