[######] [basics] Python Python presentation ######

Python is an object-oriented, interpreted computer programming language.

What is Python?

    Python (English pronunciation: / paɪθən / American pronunciation: / paɪθɑːn /), is an object-oriented computer programming language interpreted by the Dutchman Guido van Rossum in 1989 invention, the first public release was released in 1991 .

    Python is a pure free software, the source code and the interpreter CPython follow the GPL (GNU General Public License) protocol.

  Python syntax is simple and clear, one of the features is mandatory indented by whitespace (white space) as the statement.

  Python has a rich and powerful library. It is often nicknamed glue language, the other language can make various modules (especially C / C ++) easily linked together.

One common application is the case, the use of Rapid Prototyping Python program (sometimes the final program interface), then some of which special requirements, a more suitable language rewriting, such as 3D graphics rendering module in the game, performance requirements are particularly high, it can be rewritten in C / C ++, and then packaged as Python be extended library call. Note that the platform may need to consider the issue when you are using extension libraries, some may not be available for cross-platform.

 

 

Python coding 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 the advanced dynamic language) 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, the next line if the statement is not indented to the right) can not compile. One very important one is Python 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.

Design Positioning

    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. Run import this can get a complete list in the Python interpreter.

    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 in Haskell and Standard ML proven 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. Author "Python Technical Manual" Martelli (Alex Martelli), said: "It's hard to say, but, in 2004, Python has been used within Google, 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 using C ++ control hardware using Python in the rapid development time. "

carried out

    Python, when executed, will first .py file compile source code into byte code of Python (byte code), and then performs the compiled byte code from the Python Virtual Machine (Python virtual machine). The basic idea of ​​this mechanism with Java, .NET is the same. However, different Python Virtual Machine and the Java Virtual Machine or .NET is, Python's Virtual Machine is a more advanced Virtual Machine. Senior, not to say that Python is more powerful than Java Virtual Machine or .NET functionality, but that Java or .NET and compared to the distance from the real machine Virtual Machine Python farther advanced on the usual sense here. Or you can say, Python's Virtual Machine is a higher level of abstraction Virtual Machine.

    C-based Python compiled bytecode files, usually .pyc format.

    In addition, Python can also run in interactive mode, popular operating systems such as Unix / Linux, Mac, Windows can be run directly Python interactive environment directly in command mode. Direct operating instructions issued to interoperate.

Python advantages

    1. Simple: Python is a language represents the simple ideology. Reading a good Python program feels almost like reading the same in English. It allows you to focus on solving the problem rather than the language itself.

    2. learn: Python is extremely easy to use, since Python has an extraordinarily simple documentation [5].

    3. speed: the underlying Python is written in C language, a lot of standard libraries and third-party libraries are written in C, runs very fast.

    4. Free, open source: Python is one of FLOSS (free / open source software). Users can freely distribute copies of this software, read its source code, make changes to it, it's part of the new free software. FLOSS is based on the concept of sharing knowledge of a group.

    5. High-level Language: When writing programs in Python regardless of the low-level details such as how to manage a class of memory used by your program.

    6. Portability: Because of its open-source nature, Python has been ported on many platforms (changed to make it work on different platforms). 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, PocketPC, Symbian, and Google android platform is based on linux development.

    7. explanatory: for example, a C or C ++ programs written in compiled language can be converted from the source file (ie C or C ++) to the language (binary code ie 0 and 1) a computer you use. This process by the compiler and various flags and options. When running the program, the linker / loader software to copy your program from the hard disk into memory and run. Python, the program does not need to be compiled into binary code. You can run the program directly from the source code. Inside the computer, Python interpreter converts the source code into an intermediate form called bytecode, then translates it into a machine language using the computer and run. This makes using Python much easier. Python also makes the program easier to transplant.

    8. Object Oriented: Python supports both procedure-oriented programming supports object-oriented programming. In the "procedure-oriented" language, it is constructed from a program or process is simply a function of reusable code together. In the "object-oriented" language, the object program is a combination of data and functionality from the build up.

    9. Scalability: If a critical piece of code run faster or some desirable algorithms are not disclosed, may be part of a program written in C or C ++, and then use them in Python programs.

    10. Embeddability: Python can embed C / C ++ program, to provide script functionality to the user program.

    11. The rich library: Python Standard Library is huge indeed. It can help deal with a variety of work, including regular expressions, documentation generation, unit testing, threading, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, cryptography, GUI ( the graphical user interface), Tk, and other system-related operations. 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, Python Imaging Library and so on.

    12. The specification code: Python forced indented way that the code has better readability. Python, the program does not need to be compiled into binary code.

Python shortcomings

    1. The one-line command output statements and questions: In many cases the program can not be connected into a single line, such as the import sys; for i in sys.path: print i. Whereas no such restriction on awk and perl, can more easily through a simple procedure of the shell, do not need such as Python, it must be written to a file .py program.

    2. unique syntax: perhaps limitation should not be called, but it uses indentation to distinguish between statements that the relationship between the way a lot of beginners or to bring confusion. Even very experienced Python programmers, they may fall into the trap of them. The most common situation is mixed tab and space will lead to error, which is not with the naked eye, respectively.

    3. Run Slow: This refers to the comparison with C and C ++.

Python Tools

    1.Tkinter: Python default GUI interface. Tkinter is a Tk Python modules and interfaces, Tkinter library provides an interface to the Tk API, it belongs to Tcl / Tk GUI tool set.

    2.PyGTK: python GUI application development for the GTK + library. GTK and Gnome is used to achieve GIMP library.

    3.PyQt: Qt development libraries for python. QT library that implements the KDE environment, consists of a series of modules, have qt, qtcanvas, qtgl, qtnetwork, qtsql, qttable, qtui and qtxml, contains 300 classes and over 5,750 functions and methods of. PyQt also supports a module called qtext, which contains a QScintilla library. The library is a Qt Interface Scintillar editor class.

    4.wxPython: GUI programming framework, people familiar with the MFC will love, is simply the same architecture (designed for beginners or for less demanding users, the use Boa Constructor can be easily and quickly develop a wxPython)

    5.PIL: python provides powerful graphics processing capabilities, and provide a wide range of graphic file format support, the library can convert graphics formats, print and display. But also for treatment of some graphic effects, such as graphics enlargement, reduction and rotation. Python is a powerful tool for image processing user.

    6.Psyco: a accelerometer Python code, Python code execution speed can increase to the same level compiled language.

    7.xmpppy: Jabber server uses the XMPP protocol development, Google Talk IM system also uses XMPP protocol. There is a xmpppy module supports the protocol in Python. In other words, we can, is not it Cool through the module to communicate with the Jabber server.

    8.PyMedia: python modules for multimedia operations. It provides a rich and simple interface for multimedia processing (wav, mp3, ogg, avi, divx, dvd, cdda etc). It can be used in Windows and Linux platforms.

    9.Pmw: Python megawidgets, Python super GUI component set, use a high-level GUI components built in python Tkinter module, each Pmw have incorporated one or more Tkinter components to achieve more and more complex functions with.

    10.PyXML: with Python toolkit to parse and process XML documents, package 4DOM is fully compatible with W3C DOM specification. It contains the following:

Python Standard Library

    Python has a powerful standard library. The core Python language contains only numbers, strings, lists, dictionaries, and other common file types and functions, and provides a system managed by the Python standard library, additional functionality of network communication, text processing, database interfaces, graphics systems, XML processing, etc. . Python standard library naming the interface clear, well-documented, easy to learn and use.

    Python provides a large community of third-party modules, used in a manner similar to the standard library. Their function all-encompassing, covering scientific computing, Web development, database interfaces, graphics systems in many fields, and most of the mature and stable. You can use third-party modules written in C or Python. SWIG, SIP commonly used in the C language library into Python modules. Boost C ++ Libraries contains a set of libraries, Boost.Python, so that the program written in C ++ or Python can call each other. The aid has a number of tools based on the standard library, can use low-level languages ​​such as C and can be used as other library interface C ++, Python has become a powerful applied between other languages ​​and tools glue language.

 

The main features of the Python standard library are:

    1. Text processing, comprising text formatting, regular expression matching, combined with the difference calculation text, Unicode support, binary data processing functions

    2. File processing operations include files, create temporary files, file compression and archiving, configuration files and other functions operating

    3. The operating system features, including thread and process support, IO multiplexing, date and time of processing, call the system function, diary (logging) and other functions

    4. A communication network, comprising a network socket, SSL encryption communication, an asynchronous network communication functions

    5. network protocols, support HTTP, FTP, SMTP, POP, IMAP, NNTP, XMLRPC and other network protocols, and provides a framework to support the preparation of a web server W3C format, including HTML, SGML, XML processing.

    6. Other features include support for internationalization, math, HASH, Tkinter, etc.

Python development environment

  • IDLE: Python built-in IDE (python with the installation package)
  • PyCharm: JetBrains, developed by the renowned, with a set that can help users to improve their efficiency when using the Python language development tools, such as debugging, syntax highlighting, Project management, code branches, IntelliSense, auto-complete, unit testing, version control. In addition, the IDE provides some advanced features, support for professional Web development under the Django framework.
  • Komodo and Komodo Edit: the latter is the former free Lite
  • PythonWin: ActivePython or pywin32 offers the IDE, only available for Windows
  • SPE (Stani's Python Editor): free software with more features, based on wxPython
  • Ulipad: Function than the whole free software, based on wxPython; Python author is a Chinese master limodou
  • WingIDE: it may be the most full-featured IDE, but not free software (open source users and user education can apply for a free key)
  • Eric: PyQt based on free software, powerful. Full name: The Eric Python IDE
  • DrPython
  • PyScripter: use Delphi to develop lightweight open-source Python IDE, and support Python2.6 3.0.
  • PyPE: PythonIDE an open source cross-platform.
  • bpython: using the curses library developed lightweight Python interpreter under Unix-like operating system. Syntax prompts.
  • eclipse + pydev Plug: Easy debugger
  • emacs: comes with python support, auto-complete, refactor and other functions required plug-in support
  • Vim: python support can be added when compiling the latest version 7.3, providing python code automatically prompt support
  • Visual Studio 2003 + VisualPython: for Windows only, has stopped maintenance, poor function
  • SlickEdit
  • Visual Studio 2010 + Python Tools for Visual Studio
  • TextMate
  • Netbeans IDE
  • Sublime

Python famous application

    • Pylons-Web application framework
    • Zope- application server
    • Plone- content management system
    • Django- encourage the rapid development of Web application framework
    • Uliweb- people develop lightweight Web framework
    • 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
    • Micro flask- 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
    • Pylons - Web Application Framework
    • 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

 

 


-------- (I am dividing line) --------

reference:

1. https://www.w3cschool.cn/python/

 

 

Remarks:

Initial modified: October 4, 2019 15:03:27

Environment: Windows 7 / Python 3.7.2

 

Guess you like

Origin www.cnblogs.com/kaixin2018/p/11622176.html