Meet Python (Learn)

Source: Internet
Author: User

Meet Python (Learn)
I. Development background of Python
Python's author, Guido von Rossum (Gido Fan Rosum, a Chinese Python programmer all call him Uncle Turtle), the Dutchman. In 1982, Uncle Turtle received his master's degree in mathematics and computer Science from the University of Amsterdam. However, even though he is a mathematician, he enjoys the pleasure of computer. In his words, although he has both mathematics and computer qualifications, he always tends to do computer-related work and is keen to do anything and programming related things.

At that time, Uncle Turtle contacted and used such languages as Pascal, C, Fortran and so on. The basic design principles of these languages are to allow machines to run faster. In the 80 's, although IBM and Apple have set off a wave of personal computers, the configuration of these PCs is low. For example, the early Macintosh, only 8MHz CPU frequency and 128KB of RAM, a large array can fill the memory. The core of all compilers is to do optimizations so that the program can run. To improve efficiency, language also forces programmers to think like computers so that they can write programs that are more machine-flavored. In those days, programmers wanted to squeeze every inch of the computer's ability with their hands. Some people even think that the C language pointer is wasting memory. As for dynamic types, memory auto-management, object-oriented ... Don't think about it, it will paralyze your computer.

This way of programming makes Uncle Turtle feel distressed. Uncle Turtle knows how to write a function in C, but the whole writing process takes a lot of time, even if he knows exactly how to implement it. Another option for him is the shell. The Bourne shell has long existed as an interpreter for UNIX systems. UNIX administrators often use the shell to write simple scripts to perform some system maintenance tasks, such as regular backups, file system management, and so on. The shell can connect many of the features under UNIX, just like glue. Many of the C-language hundred lines of the program, under the shell only a few lines can be completed. However, the nature of the shell is to invoke the command. It's not a real language. For example, the shell has no numeric data type, and the addition operation is complex. In short, the shell does not fully mobilize the function of the computer.

Uncle Turtle wants to have a language that, like the C language, can fully invoke the computer's functional interface and can be programmed as easily as the shell. ABC language let Uncle Turtle see hope. ABC was developed by the Dutch Institute of Mathematics and Computer science. Uncle Turtle worked at the institute and was involved in the development of the ABC language. The ABC language is aimed at teaching. Unlike most languages at the time, the goal of the ABC language is to "make users feel Better". ABC language wants to make language easy to read, easy to use, easy to remember, easy to learn, and to inspire people to learn programming interest. For example, here is an ABC program from Wikipedia, which is used to count the total number of words that appear in the text:

How to RETURN words document:
PUT {} in Collection
For line in document:
For word in the split line:
IF Word not.in Collection:
INSERT Word in Collection
RETURN Collection
How to defines a function. A Python programmer should be able to understand this program very easily. The ABC language uses colons and indents to represent the program block. There is no semicolon at the end of the line. There is also no parentheses () in the for and if structures. The assignment takes a put instead of a more common equals sign. These changes make the ABC program read like a piece of text.

Despite the good readability and ease of use, the ABC language was not in vogue at the end. At the time, the ABC language compiler needed a high-profile computer to run. Users of these computers are usually proficient in computers, and they think more about the efficiency of the program than the difficulty of learning it. In addition to hardware difficulties, the design of the ABC language also has some fatal problems:

Scalability is poor. The ABC language is not a modular language. If you want to add functionality to the ABC language, such as graphical support, you have to change a lot of places.
IO cannot be done directly. The ABC language cannot directly manipulate the file system. Although you can import data in a way such as text flow, ABC cannot read and write files directly. The difficulty of input and output is fatal for computer language. Can you imagine a sports car that can't open the door?
Over-innovation. ABC uses natural language to express the meaning of the program, such as how to in the above program. For programmers, however, they are more accustomed to using functions or define to define a function. Similarly, programmers are more accustomed to assigning variables with equal signs. Although the ABC language is very special, it is very difficult to learn.
Transmission difficulties. The ABC compiler is large and must be stored on tape. When Uncle Turtle was visiting, he had to have a big magnetic to bring to someone to install the ABC compiler. In this way, the ABC language is difficult to spread quickly.
In 1989, in order to pass the Christmas holiday, Uncle Turtle began to write the Python language compiler. The name Python, from the TV show beloved by Uncle Turtle, Monty Python's Flying Circus. He hoped that the new language, called Python, would fit his ideals: create a language that is all-powerful, easy to learn, easy to use, and extensible, between C and Shell. As a language design enthusiast, Uncle Turtle has tried to design language. This time, it was just a purely hacking act.

Second, the birth of the Python language
1991, the first Python compiler was born. It is implemented in C language and can call the C language library file. From birth, Python already has: classes, functions, exception handling, core data types including tables and dictionaries, and module-based expansion systems.

Many of the python grammars come from C, but are strongly influenced by the ABC language. Some of the rules from the ABC language are still controversial today, such as forced indentation. But these syntax rules make python easy to read. On the other hand, Python's clever choices obey some conventions, especially those of the C language, such as the return equal value assignment. Uncle Tortoise believes that if the "common sense" on the establishment of things, there is no need to over-tangled.

Python has been particularly concerned about extensibility from the start. Python can be expanded on multiple levels. From the top, you can introduce directly. PY file. At the bottom, you can reference the C-language library. Python programmers can write quickly using Python. PY file as an extension module. But when performance is an important factor to consider, Python programmers can drill down to the bottom, write C programs, and compile into. So files for use in Python. Python is like a steel building, with a large frame set up first. And programmers can be quite free to expand or change in this framework.

The original python was developed entirely by Uncle Turtle himself. Python received a welcome from his colleague, Uncle Turtle. They quickly feedback the use of comments and participate in Python improvements. Uncle Turtle and some colleagues form the core team of Python. They used most of their spare time to hack Python. Later, Python expanded beyond the Institute. Python hides many of the details at the machine level, handing it over to the compiler, and highlighting logic-level programming thinking. Python programmers can spend more time thinking about the logic of the program than the specifics of the implementation. This feature attracts a large number of programmers. Python is getting popular.

Life is short, I use Python

Computer hardware is getting stronger and Python is easy to use, so many people are turning to python. Uncle Turtle maintains a mail List,python user to communicate via email. Python users come from many fields, have different backgrounds, and have different needs for python. Python is fairly open and easy to expand, so it's easy to expand or transform Python when the user isn't satisfied with the existing functionality. These users then send the changes to Uncle Turtle, who decides whether to add new features to Python or the standard library. This would be a great honor if the code could be incorporated into Python itself or the standard library. Because of his supreme decision, he was called the "Benevolent dictator of Life".

Python and its standard library are powerful. These are the contributions of the Community as a whole. Python's developers come from a variety of fields, and they bring the benefits of different areas to python. For example, the regular expressions in the Python standard library refer to Perl, while the lambda, map, filter, and reduce functions refer to Lisp. Some of the features of Python itself and most of the standard libraries come from the community. The python community is expanding to have its own newsgroup, websites, and funds. Starting with Python 2.0, Python has shifted from the development of the mail list to a fully open source development approach. Community atmosphere has been formed, work is shared by the entire community, Python has also been more rapid development.

To this day, the Python framework has been established. The Python language organizes code with objects as its core, supports multiple programming paradigms, and uses dynamic types to automate memory recovery. Python supports interpretation runs and can call the C library for expansion. Python has a strong standard library. As the standard library system is stable, the Python ecosystem begins to expand to third-party packages. These packages, such as Django, web.py, Wxpython, NumPy, Matplotlib, and PIL, have upgraded python to a species-rich rainforest.

Python advocates beauty, clarity and simplicity, and is an excellent and widely used language. Python ranked eighth in the Tiobe rankings, Google's third-largest development language, Dropbox's base language, and Watercress's server language. The history of Python can serve as a representative and give me a lot of revelation.

The community has played an important role in Python's development process. Uncle Turtle thinks he is not an all-round programmer, so he is only responsible for framing. If the problem is too complicated, he will choose to go around, that is, cut the corner. These issues are ultimately addressed by others in the community. The people in the community are exceptionally rich, and even creating a website, raising funds and so on with the development of something far away, there are people willing to deal with. Today's project development is becoming more complex, larger, more collaborative, and open-minded as the key to the ultimate success of the project.

Python has learned a lot from other languages, whether it's ABC, which is already in the history, or the C and Perl that are still in use, and many other languages that are not listed. It can be said that Python's success represents the success of all the languages it draws upon. Similarly, Ruby draws on Python, and its success also represents some aspects of Python's success. Every language is a mixture, has its excellent place, but also has a variety of defects. At the same time, a language "good and bad" judgment, often constrained by the platform, hardware, the Times and so on external reasons. Programmers have been through a lot of language battles. In fact, with an open mind to accept the language, perhaps one day, the programmer can be like Uncle Turtle, mixed up their own language.

Three, the key point of common sense
The pronunciation and spelling of Python
The author of Python is Guido van Rossum (Uncle Tortoise)
Python was formally born in 1991
Python's interpreter is now available in several languages, and we often use CPython (the official version of the C language implementation), as well as Jython (which can run on the Java platform), IronPython (which can run on the. NET and mono platforms), PyPy (Python-enabled, JIT-on-the-fly compilation)
Python currently has two versions, Python2 and Python3, and the latest version is 2.7.13 and 3.6.2
Life are shot, you need Python. Life is short, I use Python.
Programming language Leaderboard

(August 2017, TIOBE programming language popularity rankings)

Iv. advantages and disadvantages of Python
Advantages
Simple: Python is a language that represents the idea of simplicity. Reading a good Python program feels like reading English, even though the requirements of this English are very strict! This pseudo-code nature of Python is one of its greatest advantages. It allows you to focus on solving problems rather than figuring out the language itself.

Easy to learn: As you will see, Python is extremely easy to get started with. As mentioned earlier, Python has a very simple syntax.

Free, open Source: Python is one of floss (free/open source software). Simply put, you are free to publish a copy of the software, read its source code, make changes to it, and use it as part of the new free software. Floss is the concept of sharing knowledge based on a group. That's one of the reasons why Python is so good-it's created and constantly improved by a group of people who want to see a better python.

High-level languages: When you write programs in the Python language, you don't have to consider the underlying details such as how to manage the memory used by your program.

Portability: Because of its open source nature, Python has been ported on many platforms (modified to make it work on different platforms). If you are careful to avoid using system-dependent features, all your Python programs can run without modification on any of the platforms listed below. These platforms include Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, as/400, BeOS, os/390, z/OS, Palm OS, QNX, VMS, Psion, Acom RISC OS, VxWorks, PlayStation, sharp Zaurus, Windows CE and even PocketPC, Symbian, and Google Linux-based Android platforms!

Interpreted language: A program written in a compiled language, such as C or C + +, can be converted from a source file (that is, C or C + +) to a language used by your computer (binary code, 0 and 1). This process is done through the compiler and different tags and options. When you run your program, the connection/reprint software copies your program from the hard disk into memory and runs. Programs written in the Python language do not need to be compiled into binary code. You can run the program directly from the source code. Inside the computer, the Python interpreter translates the source code into an intermediate form called bytecode, and then translates it into the machine language used by the computer and runs it. In fact, because you no longer need to worry about how to compile the program, how to make sure that the connection is reprinted with the correct library, and so on, all this makes using Python easier. Since you only need to copy your Python program to another computer, it will work, which makes your Python program easier to migrate.

Object-oriented: Python supports both process-oriented programming and object-oriented programming. In a "process-oriented" language, a program is built from a procedure or simply a function of reusable code. In "Object-oriented" languages, programs are built from objects that combine data and functionality. Python implements object-oriented programming in a very powerful and simple way, compared to other major languages such as C + + and Java.

Extensibility: If you need a piece of your critical code to run faster or you want some algorithms to be private, you can write some of your programs in C or C + + and then use them in your Python program.

Rich Library: The Python standard library is really huge. It can help you with all kinds of work, including regular expressions, document generation, unit tests, threads, databases, Web browsers, CGI, FTP, e-mail, XML, XML-RPC, HTML, WAV files, cryptography systems, GUI (graphical user interface), TK, and other system-related operations. Remember that all of these features are available as long as Python is installed. This is called Python's "fully functional" concept. In addition to the standard library, there are many other high-quality libraries, such as Wxpython, twisted, and Python image libraries, and so on.

Canonical code: Python uses forced indentation to make the code extremely readable.

Disadvantages
Python language is very perfect, there is no obvious short board and shortcomings, the only drawback is that the implementation of slow, this is the interpretation of the language, and this shortcoming will be the computer more and more powerful performance to compensate.

V. Python application Scenarios
Web application Development

Python is often used for web development. For example, with the Mod_wsgi module, Apache can run web programs written in Python. Python defines the WSGI standard application interface to coordinate the communication between the HTTP server and the Python-based Web program. Some web frameworks, such as django,turbogears,web2py,zope, can make it easy for programmers to develop and manage complex web programs.

Operating System Management, server operations Automation scripts

In many operating systems, Python is the standard system component. Most Linux distributions, as well as NetBSD, OpenBSD, and Mac OS X, are integrated with Python and can be run directly under the terminal. Some installers for Linux distributions are written in the Python language, such as the Ubuntu ubiquity Installer, Red Hat Linux, and Fedora's Anaconda installer. Gentoo Linux uses Python to write its Portage package management system. The Python standard library contains multiple libraries that invoke operating system functionality. By Pywin32 This third-party package, Python has access to Windows COM services and other Windows APIs. Use the Ironpython,python program to directly invoke the. Net Framework. In general, the system management scripts written by Python are superior to normal shell scripts in terms of readability, performance, code reuse, and extensibility.

Web crawler

Python has a large number of HTTP request processing libraries and HTML parsing libraries, and has a mature and efficient crawler framework scrapy and distributed Solutions Scrapy-redis, the application of crawler is very extensive.

Scientific calculations

NumPy, SciPy, Pandas, matplotlib allow Python programmers to write scientific computing programs.

Desktop software

PyQt, Pyside, WxPython, and PYGTK are a powerful tool for Python to rapidly develop desktop applications.

Server Software (network software)

Python's support for various network protocols is perfect, so it is often used to write server software and web crawlers. The third-party library twisted supports asynchronous network programming and most standard network protocols (including clients and servers), and provides a variety of tools that are widely used to write high-performance server software.

Game

Many games use C + + to write high-performance modules such as graphical display, while using Python or Lua to write game logic, servers. Compared to Python,lua, the functionality is simpler and smaller, while Python supports more features and data types.

Concept implementation, early prototyping and iteration of the product

Google, NASA, and Facebook are using Python extensively in their own way.

Meet Python (Learn)

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.