Basic Python Tutorials

Source: Internet
Author: User

Tags: lips google basic designer Django asynchronous overloaded operator operator

What is python?

Python (United Kingdom pronunciation:/?pa?θ?n/American pronunciation:/?pa?θɑ?n/) is an object-oriented, interpreted computer programming language, invented by Dutch Guido van Rossum in 1989, and the first public offering was released in 1991.

If you want to learn jquery faster and more systematically, you'd better take a learning approach (Python micro Lesson ).

Python is purely free software, and the source code and interpreter CPython follow the GPL (GNU general public License) agreement. Python syntax is simple and clear, and one of the features is to force whitespace (white space) to be indented as a statement. Python has a rich and powerful library. It is often nicknamed the glue language and is able to easily connect a variety of modules made in other languages, especially in C + +. A common application scenario is to use Python to quickly build a prototype of a program (sometimes even the final interface of the program) and then rewrite it in a more appropriate language, such as a graphics rendering module in a 3D game, with a particularly high performance requirement, and can be rewritten in C + + with a specially requested part. It is then encapsulated as an extension class library that Python can call. It is important to note that you may need to consider platform issues when you use the Extended class library, and some may not provide cross-platform implementations.

python coding style

Python is designed with a clear, consistent style, which makes Python an easy-to-read, easy-to-maintain, widely-used language that is popular with many users.

The overall guiding ideology of designer development is that, for a particular problem, there is only one best way to solve it. This is stated in the Python motto (known as the Zen of Python) written by Tim Peters: there should be one--and preferably only one--obvious the-do it. This is exactly the opposite of the central idea of the Perl language (another feature-like advanced Dynamic language), TMTOWTDI (there's more Than one-way-to-do It).

Python authors intentionally design restrictive grammars that make bad programming habits (such as the next line of an if statement not indented to the right) fail to compile. One of the most important is the Python indentation rules.

The difference between one and most other languages, such as C, is that the bounds of a module are determined entirely by the position of the first character of each line in that line (and the C language is explicitly defined by a pair of curly braces {} to define the bounds of the module, which has no relation to the position of the character). This has been controversial. Since the birth of a language such as C, the grammatical meaning of the language is separated from the arrangement of the characters, which was once thought to be the progress of a programming language. It is undeniable, however, that Python does make the program clearer and more beautiful by forcing programmers to indent, including if,for and function definitions, where all the modules need to be used. Design Positioning

Python's design philosophy is "elegant", "clear", "simple". Therefore, the idea that "there are always multiple ways to do the same thing" in the Perl language is often unbearable for Python developers. The Python developer's philosophy is "in one way, it's best to have only one way to do something." When designing the Python language, Python developers tend to reject the fancy syntax when faced with a variety of options, and choose a syntax that is unambiguous and has little or no ambiguity. Because of this conceptual difference, Python source code is often thought to be more readable than Perl and can support large-scale software development. These guidelines are called Python maxims. Run import this in the Python interpreter to get a complete list.

Python developers try to avoid immature or unimportant optimizations. Patches that speed up operations against non-essential parts are usually not incorporated into Python. So many people think that Python is slow. However, according to the 28 law, most programs do not require high speed. In some cases where the speed requirements are high, Python designers tend to use JIT technology, or rewrite this part of the program in C + + language. The available JIT technology is pypy.

Python is a fully object-oriented language. Functions, modules, numbers, and strings are objects. and fully support inheritance, overloading, derivation, multi-inheritance, beneficial to enhance the reusability of the source code. Python supports overloaded operators and dynamic types. Python has limited support for functional design compared to Lisp, a traditional functional programming language. There are two standard libraries (Functools, itertools) that provide proven functional programming tools in Haskell and standards ml.

Although Python may be roughly categorized as a "scripting language" (script language), some large-scale software development programs such as Zope, Mnet, and Bittorrent,google are also widely used. Python supporters prefer to call it a high-level dynamic programming language because the "scripting language" refers to a language that is designed only for simple programming tasks, such as Shellscript, VBScript, and so on, which can only handle simple tasks, and cannot be compared to Python.

Python itself is designed to be extensible. Not all features and functionality are integrated into the language core. Python provides a rich range of APIs and tools so programmers can easily write extensions using C, C + +, Cython. The Python compiler itself can also be integrated into other programs that require scripting languages. As a result, many people also use Python as a "glue language" (glue language). Use Python to integrate and encapsulate programs written in other languages. Many projects within Google, such as Google Engine, use C + + to write high-performance parts, and then call the appropriate modules in Python or java/go. Alex Martelli, author of the Python Technical handbook, said: "It's hard to say, but in 2004, Python was used inside Google, and Google recruited many Python gurus, but before that, Martelli had decided to use Python. Their purpose is python where we can, C + + where we must, use C + + in the case of hardware manipulation, using Python in rapid development. The execution

When Python executes, the source code in the. py file is first compiled into Python's byte code (bytecode), which is then executed by Python virtual machine (python vm) to execute the compiled byte code. The basic idea of this mechanism is with Java,. NET is consistent. However, Python virtual machine differs from Java or. NET virtual machine in that Python's virtual machine is a more advanced virtual machine. The high-level here is not in the usual sense, not that Python's virtual machine is more powerful than Java or. NET, but rather that Python's virtual machines are farther away from the real thing than Java or. Net. Or so, Python's virtual machine is a higher-level, more abstract virtual machine.

A C-based Python-compiled bytecode file, usually the. pyc format.

In addition, Python can also run in interactive mode, such as the main operating system Unix/linux, MAC, Windows can directly run the Python interactive environment directly in command mode. The direct release of the operation instructions allows for interactive operation. Python Benefits

1. Simple: Python is a language that represents the idea of simplicity. Reading a good Python program feels like reading English. It allows you to focus on solving problems rather than figuring out the language itself.

2. Easy to learn: Python is extremely easy to get started because Python has a very simple documentation [5].

3. Fast: The bottom of Python is written in C, many standard libraries and third-party libraries are written in C, running very fast.

4. Free, open Source: Python is one of floss (free/open source software). The user is free to publish copies 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.

5. High-level languages: When writing programs in the Python language, you do not have to consider the underlying details such as how to manage the memory used by your program.

6. Portability: Because of its open source nature, Python has been ported on many platforms (modified to enable it to 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 Linux-based Android platforms.

7. Explanatory: A program written in a compiled language such as C or C + + can be converted from a source file (i.e. C or C + +) to a language used by your computer (binary code, i.e., 0 and 1). This process is done through the compiler and different tags and options. When you run the 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. This makes it easier to use Python. It also makes Python programs easier to migrate.

8. 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.

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

10. embeddable: Python can be embedded in a C + + program to provide scripting functionality to program users.

11. Rich libraries: The Python standard library is really huge. It can help 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. 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.

12. Canonical code: Python uses forced indentation to make the code more readable. Programs written in the Python language do not need to be compiled into binary code. python drawbacks

1. Single-line statements and command-line output problems: Many times you cannot write a program to a line, such as import sys;for I in Sys.path:print i. Perl and awk do not have this limitation, it is easier to complete a simple program under the shell, do not need to like Python, the program must be written to a. py file.

2. Unique syntax: This may not be referred to as limitation, but it is also confusing for many beginners by narrowing the way in which the statement relationship is differentiated. Even the most experienced Python programmers can get caught up in a trap. The most common scenario is that the mix of tabs and spaces can cause errors, which cannot be separated by the naked eye.

3. Slow running: This is compared to C and C + +. Python Tools

1.tkinter:python the default GUI interface. Tkinter is a Python module with the TK interface, and the Tkinter library provides an interface to the TK API, which belongs to the TCL/TK GUI tool group.

2.PyGTK: GTK + library for Python GUI program development. GTK is the library used to implement GIMP and gnome.

3.PYQT: QT Development library for Python. QT is the library that implements the KDE environment, consisting of a series of modules, QT, Qtcanvas, QTGL, Qtnetwork, Qtsql, qttable, Qtui and Qtxml, containing 300 classes and more than 5,750 functions and methods. PYQT also supports a module called Qtext, which contains a Qscintilla library. The library is the QT interface for the Scintillar editor class.

4.wxpython:gui programming framework, people who are familiar with MFC will be very fond of, is simply the same architecture (for beginners or for users with low design requirements, the use of Boa constructor can be convenient and rapid development of WxPython)

5.pil:python provides powerful graphics processing capabilities and provides a wide range of graphics file format support, which can be converted, printed and displayed in a graphical format. Also can do some graphics effect processing, shape enlargement, reduction and rotation and so on. is a powerful tool for Python users to perform image processing.

6.Psyco: A Python code accelerometer that allows Python code to execute at the same level as the compiled language.

The 7.xmpppy:jabber server employs the developed XMPP protocol, and Google Talk is an IM system using the XMPP protocol. There is a xmpppy module in Python that supports this protocol. That is to say, we can communicate with the Jabber server through this module, is not very cool.

8.PyMedia: Python module for multimedia operations. It offers a rich and simple interface for multimedia processing (WAV, MP3, OGG, AVI, DivX, DVD, Cdda etc). Can be used under Windows and Linux platforms.

9.pmw:python Megawidgets,python Super GUI component set, a high-level GUI component built with Tkinter modules in Python, each PMW incorporates one or more tkinter components for more useful and complex functionality.

10.PyXML: The toolkit for parsing and processing XML documents in Python, the 4DOM in the package is fully compatible with the specifications of the code. It contains the following: Python standard library

Python has a strong standard library. The core of the Python language contains only the common types and functions of numbers, strings, lists, dictionaries, files, and the Python standard library provides additional functions such as system management, network communication, text processing, database interfaces, graphics systems, XML processing, and so on. The Python standard library has a clear naming interface, good documentation, and is easy to learn and use.

The Python community provides a number of third-party modules that are used in a way similar to standard libraries. Their functions are all-encompassing, covering scientific computing, web development, database interfaces, graphics systems in many areas, and mostly mature and stable. Third-party modules can be written in Python or C language. Swig,sip is often used to convert a library written in C into a Python module. The Boost C + + libraries contains a set of libraries that are boost.python so that programs written in Python or C + + can invoke each other. With a large number of tools based on the standard library, the ability to use low-level languages such as C and C++,python, which can be used as other library interfaces, has become a powerful glue language applied to other languages and tools.

The main features of the Python standard library are:

1. Text processing, including text formatting, regular expression matching, text difference calculation and merging, Unicode support, binary data processing and other functions

2. File processing, including file operations, create temporary files, file compression and archiving, operation profiles and other functions

3. Operating system features, including threading and process support, IO multiplexing, date and time processing, call system functions, write journaling (logging) and other functions

4. Network communication, including network sockets, SSL encrypted communication, asynchronous network communication and other functions

5. Network protocol, support HTTP,FTP,SMTP,POP,IMAP,NNTP,XMLRPC and other network protocols, and provide a framework for writing network server Web-format support, including html,sgml,xml processing.

6. Other functions, including international support, Math, HASH, Tkinter and other Python development environment

  • Idle:python built-in IDE (supplied with Python installation package)
  • Pycharm: Developed by a well-known JetBrains company with a set of tools to help users improve their efficiency when developing with the Python language, such as debugging, syntax highlighting, project management, code jumps, smart tips, AutoComplete, unit tests, version control. In addition, the IDE provides advanced features to support professional web development under the Django framework.
  • Komodo and Komodo Edit: the latter is a free lite version of the former
  • The IDE is available in Pythonwin:activepython or Pywin32 only for Windows
  • SPE (Stani's Python Editor): Free software With more features, based on Wxpython
  • Ulipad: Free software with more functions, based on Wxpython; the author is a Chinese python master Limodou
  • Wingide: Probably the most functional IDE, but not free software (educational users and open source users can apply for free key)
  • Eric: PYQT-based free software, powerful. The full name is: the Eric Python IDE
  • Drpython
  • Pyscripter: A lightweight open source Python IDE developed with Delphi that supports Python2.6 and 3.0.
  • Pype: An open source cross-platform Pythonide.
  • Bpython: A lightweight Python interpreter developed under the Unix-like operating system using the curses library. Syntax hints feature.
  • Eclipse + Pydev Plugin: Easy to debug program
  • Emacs: With Python support, auto-complete, refactor and other functions require plug-in support
  • Vim: Python support can be added to the latest version 7.3 compilation, providing automatic hint support for Python code
  • Visual Studio 2003 + Visualpython: Windows only, discontinued maintenance, poor functionality
  • SlickEdit
  • Visual Studio + Python Tools for Visual Studio
  • TextMate
  • Netbeans IDE
  • Sublime
Python's famous app
    • Pylons-web Application Framework
    • zope-Application Server
    • plone-Content Management System
    • Django-encourages rapid development of Web application frameworks
    • A lightweight web framework developed by uliweb-
    • turbogears-Another Web application rapid development Framework
    • Twisted--python's Network application framework
    • Python Wikipedia Robot framework-mediawiki Robot Program
    • Wiki program written by Moinmoinwiki-python
    • Flask-python Micro Web Framework
    • tornado-non-blocking server
    • Webpy-python Micro Web Framework
    • Bottle-python Micro Web Framework
    • eve-Online game Eve is heavily developed using Python
    • Reddit-Social sharing site
    • Dropbox-File Sharing service
    • Pylons-web Application Framework
    • TurboGears-Another Web application rapid development Framework
    • Fabric-Libraries for managing hundreds of thousands of Linux hosts
    • Trac-a bug management system written using Python
    • Mailman-mailing list software written using Python
    • Mezzanine-Content management system based on Django
    • Blender-Open Source 3D drawing software developed in C and Python
Additional Information

Official website: https://www.python.org/

API Document: https://docs.python.org/3/

Download: https://www.python.org/downloads/

Tutorial: http://www.w3cschool.cn/python/python-tutorial.html

Basic Python Tutorials

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.

Tags Index: