Python's Python origins, language features __python

Source: Internet
Author: User
Tags data structures exception handling stack trace
One, 1.1 what is Python
Python is an elegant and robust programming language that inherits the power and versatility of the traditional compiler language, as well as the ease of use of simple scripts and interpreting languages. It can help you get the job done, and after a while you'll be able to see the code you've written. You'll be amazed at how quickly you learn it and its powerful features, not to mention the work you've done. Only you can't imagine, no Python.

Two, 2 1.2 origins
Fan Rossam (Guido van Rossum) founded Python at the end of 1989, when he was also in the Netherlands CWI (Centrum voor Wiskunde en Informatica, National Institute of Mathematics and Computer science). In early 1991, Python released its first public release. How did it all start? Like C, C + +, Lisp, Java, and Perl, Python comes from a research project where programmers work hard with the tools they have at hand, and they envision and develop better solutions.

At that time Fan Rossam was a researcher who had extensive design experience with the explanatory language ABC, which was also developed in CWI. But he is not satisfied with his limited ability to develop. After using and participating in the development of a high-level language such as ABC, it is clearly impossible to return to the C language. Some of the tools he expects are used to perform day-to-day system management tasks, and it also wants access to system calls to amoeba distributed operating systems. Although Fan Rossam had thought of developing a dedicated language for amoeba, it was clearly wiser to create a generic programming language, so the seeds of Python were sown at the end of 1989.

Three, 3 1.3 features
Although Python has been popular for more than 15 years, some people still think it is a new ding relative to the general software development industry. We should use the word "relative" cautiously, because the "network age" of the program development, a few years to see
Going up like decades. When people ask: "What is Python?" , it is difficult to describe it with any image. People are more inclined to say what they feel about python all at once, and Python is ___ (please fill in) and what are these features? In order for you to know why, we will explain these features in one way or the next.
1.3.1 Advanced
With each generation of programming languages, we will reach a new level. Assembly language is a gift from God to those struggling with machine code, and later with FORTRAN, C, and Pascal, which elevate computing to a new level and create a software development industry. With the birth of C language more like C + +, Java, such as modern compiler language. We didn't stop here, so we had powerful, system-ready, interpretive scripting languages such as TCL, Perl, and Python.
These languages have advanced data structures that reduce the time required for previous "framework" development. Lists like Python (variable-size arrays) and dictionaries (hash tables) are built into the language itself. Providing these important building blocks in the core language can encourage people to use them, shorten development time and code, and produce more readable code. In C, there are no corresponding standard libraries for promiscuous arrays (lists in Python) and hash tables (dictionaries in Python), so they are often repeated and copied to each new project. This process is confusing and prone to errors. C + + uses the standard Template Library to improve this situation, but the standard Template library is hard to compare with the simplicity and readability of a Python-built list and dictionary.
1.3.2 Object Oriented
Recommendation: Object-oriented programming adds new vigor to the structured and procedural programming of data and logic separation. Object-oriented programming supports the integration of specific behaviors, attributes, and/or functions with the data that they want to process or represent.
The object-oriented nature of Python is innate. However, Python does not want Java or Ruby to be just an object-oriented language, but in fact it blends a variety of programming styles. For example, it even borrows some of the features of functional languages like Lisp and Haskell.
1.3.3 can be upgraded
Python is often likened to a shell under a batch or Unix system. Simple shell scripts can be used to handle simple tasks, even if they can grow at length (without limits), but the functionality will always be exhausted. The code reuse of shell scripts is low, so you can only stop at small projects. In fact, even small projects can cause scripts to stink and grow. Python is not, and you can constantly refine your code in each project, add additional new or existing Python elements, and reuse the code in your mind. Python advocates simple code design, advanced data structures, and modular components that allow you to increase the scope and scale of your project while ensuring flexibility, consistency, and shortening the necessary debugging time. The term "upgradeable" is most often used to measure the load on hardware, typically the performance improvement that comes with adding new hardware to the system. We are happy to differentiate this quote concept here, and we are trying to convey an idea with "upgradeable": Python provides a basic development module where you can develop your software, and when these need to expand and grow, Python Pluggable and modular architecture can make your project dynamic and manageable.
1.3.4 can be extended
Even if you have a lot of Python code in your project, you can still organize it methodically by separating it into multiple files or modules. And you can pick the code from one module and read the attribute from another module. Even better, Python's access syntax is the same for all modules. Whether the module is in the Python standard library or you created it a minute ago, even the extensions you write in other languages are fine. With these characteristics, you will feel that you have "expanded" the language as needed, and that you have already done so. Bottlenecks in your code may be those that are always in front of you in the performance analysis, or places that are particularly stressed, and can be rewritten as Python extensions with C. It should be reiterated that these interfaces are identical to the interfaces of a pure Python module, and that the access methods of code and objects are exactly the same. The only difference is that the code provides a significant boost to performance. Naturally, it all depends on your application and its need for resources. In many cases, the bottleneck part of using compiled code rewriting programs is definitely beneficial, as it can significantly improve overall performance.
This scalability in programming languages allows engineers to flexibly attach or customize tools to shorten the development cycle. Although mainstream third-generation languages (3GL) like C, C + + and Java have this feature, it is indeed Python's advantage to write extensions with C so easily. In addition, there are tools like PyRex that allow mixed programming of C and Python, making it easier to write extensions because it translates all the code into C language code. Because Python's standard implementation is done in C (that is, CPython), use C and C + + to write Python extensions. Python's Java implementation is called Jython, and Java is used to write its extensions. Finally, there is the IronPython, which is a C # implementation for the. NET or Mono platform. You can use C # or vb.net to extend IronPython.
1.3.5 Portability
Python can be seen on a variety of systems, thanks to the continued rapid growth of python in today's computing world. Because Python is written in C, and because of the portability of C, Python can run on any platform with the ANSI C compiler. Although there are some specific modules developed for different platforms, generic software developed in Python on any platform can be modified or run on other platforms intact. This portability applies to different architectures as well as to different operating systems.
1.3.6 Easy to learn
Python has fewer keywords, simple structure and clear syntax. This makes it easier for learners to get started in a relatively short period of time. For beginners, what may feel fresher is probably the object-oriented nature of Python. People who have not yet fully mastered OOP (object oriented programming, object-oriented programming) have scruples about using Python directly, but OOP is not necessarily or mandatory. It's also easy to get started, so you can start with a little bit of it until you're ready.
1.3.7 Easy to read
The significant difference between Python and other languages is that it has no other language commonly used to access variables, define blocks of code, and command symbols for pattern matching. Usually these symbols include: Dollar sign ($), semicolon (;), wave (~), and so on. Without these distracting guys, the Python code becomes more well-defined and easier to read. To the dismay of many programmers (or thankfully), unlike other languages, Python does not give you much opportunity to write arcane code, but to allow others to quickly understand the code you write, and vice versa. As mentioned earlier, the readability of a language makes it easier to learn. We even ventured to claim that the code was fairly easy to understand even for people who hadn't even seen a single line of Python code before.
1.3.8 Easy to maintain
Source code maintenance is part of the life cycle of software development. As long as it is not replaced by other software or abandoned, your software will usually continue to be developed. This is usually a lot longer than a programmer working in a company. The success of the Python project owes much to the ease of maintenance of its source code, which depends on the length and complexity of the code. However, it is not difficult to draw this conclusion, because Python itself is easy to learn and read. Another exciting advantage of Python is that when you read the script you wrote six months ago, you don't make yourself confused, and you don't need a reference manual to read your software.
Robustness of 1.3.9
There is nothing more effective than allowing programmers to provide processing mechanisms based on error conditions when errors occur. For errors, Python provides a "safe and reasonable" exit mechanism that allows programmers to control the situation. Once your Python crashes, the interpreter turns out a "stack trace" that has all the information available, including the reason for your program crashing and the code (file name, number of rows, number of calls, and so on) that went wrong. These errors are called exceptions. If this error occurs at run time, Python enables you to monitor these errors and handle them. These exception handling can take actions such as resolving problems, redirecting the flow of the program, performing cleanup or maintenance steps, shutting down the application normally, or simply ignoring it. In any case, this can effectively reduce the debugging process in the development cycle. Python's robustness is helpful to both software designers and users. As soon as some errors are handled incorrectly, Python also provides some information, and the stack trace that is generated as a result of an error can not only describe the type and location of the error, but also
Can indicate the module in which the code resides.
1.3.10 efficient rapid prototyping development tools
We've already mentioned how easy it is to read Python. But, you might ask, BASIC is the same, what is Python's outstanding? Unlike those closed-rigid languages, Python has many interfaces to other systems, powerful enough to be strong enough to use Python to develop a prototype of the entire system. Obviously, the traditional compiled language can also implement the same system modeling, but the simplicity of the Python work allows us to do the same work in the same time. In addition, you have developed a large number of extensions for Python, so no matter what kind of application you plan to develop, you may find predecessors. All you have to do is Plug and Play (and configure yourself, of course). As long as you can think of it, Python modules and packages can help you achieve it. The Python standard library is complete, and if you can't find what you need in it, a Third-party module or package will be available for you to do your job.
1.3.11 Memory Manager
The biggest drawback of C or C + + is that memory management is the responsibility of the developer. So even for an application that rarely accesses, modifies, and manages memory, programmers must perform these duties outside of the basic tasks. The unnecessary burdens and responsibilities that are imposed on developers are often distracting. In Python, because memory management is the responsibility of the Python interpreter, developers can liberate themselves from memory transactions, concentrate on the most immediate goals, and devote themselves solely to the development of the primary application in the plan. This causes fewer errors, more robust programs, and shorter development cycles.
1.3.12 interpretive and (byte) compilation
Python is an interpreted language, which means that there is no compilation in the development process. Generally speaking, a purely interpreted language is usually slower than a compiled language because it is not run with native machine code. However, similar to the fact that Java,python is actually byte-compiled, the result is that it can produce an intermediate form of approximate machine language. This not only improves the performance of Python, but also keeps the advantages of an interpreted language.

Description: From the second edition of Python core programming, thanks to the editor.

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.