A, Python style
Python is designed to adhere to a clear and uniform style, which makes Python become an easy to read, easy to maintain, and is welcomed by the large number of users, the use of a wide range of languages.
When designers to develop general guiding principle is that, for a particular problem, as long as there is a best way to fix it. This is written by Tim Peters of Python motto (called The Zen of Python) which is expressed as:. There should be one-- and preferably only one --obvious way to do it and this is just Perl language (another feature similar advanced dynamic languages ) the central idea TMTOWTDI (There's More Than One Way To Do It) exactly the opposite.
Python's author intended design very restrictive syntax, making bad programming practice (for example, if the statement of the next line is not indented to the right) can not compile. One very important one is Python's indentation rules.
And a majority of other languages (such as C) difference is that the boundaries of a module, is entirely determined by the first character of each line in the position of this line (The C language is a pair of curly braces {} to clear fix module boundaries, and nothing to do with the position of the character). This has caused controversy. It C Ever since the birth of this kind of language, grammatical meaning and arrangement of characters separated from the language, once considered the progress of a programming language. But it is undeniable that by forcing programmers indent (including all places need to use the module if, for and function definitions, etc.), Python really makes the program more clear and beautiful.
Two, Python's design orientation
Python's design philosophy is "elegant", "clear", "simple." Therefore, Perl language in "Always There are several ways to do the same thing" concept in Python developer is usually unbearable. Python developer's philosophy is "in a way, the best is only one way to do a thing." In the design of the Python language, if faced with a variety of options, Python developers generally refuse fancy syntax, and the choice is clear with little or no ambiguous grammar. Because of this difference in design concept, Python source code is generally considered to have more readable than Perl, and is capable of supporting large-scale software development. These guidelines are called Python motto. In the Python interpreter to run import this can be achieved within a complete list.
Python developers try to avoid premature or minor optimizations. For a number of non-essential parts of the run faster patches are usually not incorporated into the Python. So many people think Python is slow. However, according to the twenty-eight law, most programs do not ask for speed. In some cases of very high speed requirements, Python designers tend to use JIT techniques, or by using the C / C ++ language rewriting this part of the program. JIT technology is available PyPy .
Python is fully object-oriented language. Functions, modules, numbers, strings are objects. And fully supports inheritance, overloading, derived, multiple inheritance, enhance the beneficial reuse of source code. Python supports overloaded operators and the dynamic type. Lisp relative to the traditional functional programming language, Python for functional design offers only limited support. There are two standard library (functools, itertools) provided Haskell and Standard ML proven in functional programming tool.
While Python may be roughly classified as a " scripting language " (script language), but in fact a number of large-scale software development programs such as Zope , Mnet and BitTorrent, Google is also widely use it. Python's supporters prefer to call it a high-level dynamic programming language, because "scripting language" refers only language for simple programming tasks, such as shellscript, VBScript and other programming languages can only handle simple tasks, and can not be Python par.
Python itself is designed to be scalable. Not all features and functions are integrated into the core language. Python provides a rich API and tools so programmers can easily use the C language , C ++ , Cython to write Expansion Module. Python compiler itself can also be integrated into other programs require scripting language. Therefore, many people also use Python as a "glue language" (glue language). Using Python programs written in other languages will be integrated and packaged. In many projects within Google, such as Google Engine written in C ++ high performance requirements, then call the appropriate module in Python or Java / Go. " Python Technical Manual Author" Martelli (Alex Martelli), said: "It's hard to say, but, in 2004, Python has Google uses an internal, Google recruited many Python expert, but before that had decided to use Python their purpose is to Python where we can, C ++ where we must, in the case of control hardware using C ++ , Python use in the rapid development time. "
Third, the basic grammar
One of the design goals is to make Python code for a high degree of readability. It is to make use of English words and punctuation other languages commonly used design-time, so the code looks clean and beautiful. Unlike other static languages such as C, Pascal written declaration that need to be repeated, nor their syntax as often there are special circumstances and unexpected.
Python developers intend to give in violation of the indentation rules of procedure can not be compiled in order to force programmers to develop good programming habits. Python language and use indention start and exit the block of statements (Off-side rules) instead of using braces or some keywords. Increase Indent indicates the start of a block of statements, while reducing the indentation, said exit statement block. Indent became part of the syntax. For example if statement: python3
Under PEP, we must use four spaces to represent each level of indentation (4 spaces clear provisions on how, in the actual preparation can customize the number of spaces, but to satisfy an equal number of spaces between each level of indentation). Use the Tab character and the number of spaces although other can be compiled through, but do not meet coding standards. Support Tab character and other number of spaces is just as compatible with very old Python program and some editing program in question.
Fourth, the well-known applications
Digwebs-Web application framework
Pylons - Web Application Framework
Zope - Application Server
Plone - Content Management System
Django- encourage the rapid development of Web application framework
Uliweb - lightweight Web development framework people
TurboGears- another Web application framework for rapid development
Twisted - Python web application framework
Python Wikipedia Robot Framework- MediaWiki robot program
MoinMoinWiki- Python program written in Wiki
the Flask - Micro Python Web framework
tornado- non-blocking server
Micro Webpy- Python Web framework
Micro Bottle- Python Web framework
EVE- online game EVE extensive use of Python for development
Reddit - a social sharing sites
Dropbox - file-sharing service
TurboGears - another Web application framework for rapid development
Fabric - libraries used to manage hundreds or thousands of Linux hosts
Trac - written using Python BUG management system
Mailman - written in Python mailing list software
Mezzanine - based content management system written in Django
Blender - open source 3D graphics software developed C and Python