Python Basics: Initial

Source: Internet
Author: User

1) Python main areas of application:                                                                                                                                                                                                                       

    • Cloud computing : The hottest language in cloud computing, typically using OpenStack
    • Web Development : A number of excellent web frameworks, many large sites are Python development, Youtube, Dropbox, watercress ... , a typical web framework has Django
    • Scientific Computing, artificial intelligence : Typical library numpy, SciPy, matplotlib, Enthought Librarys,pandas
    • system Operation and maintenance: the necessary language for operation and maintenance personnel
    • Finance : quantitative trading, financial analysis, in the field of financial engineering, Python is not only used, but also used the most, and the importance of the year. Reason: As a dynamic language Python, the language structure is clear and simple, the library is rich, mature and stable, scientific calculation and statistical analysis are very good, production efficiency is much higher than c,c++,java, especially good at strategy backtesting
    • graphical GUI: PyQT, Wxpython,tkinter

2) Language Features:                                                                                                                                                                                                                                          

is a dynamic and explanatory strong type definition language

Programming languages SEE: Programming language classification

3) Python pros and cons:                                                                                                                                                                                                                                

Advantages:

    1. Python's positioning is "elegant", "clear", "simple"
    2. development efficiency is very high, Python has a very powerful third-party library , basically you want to achieve any function through the computer, the Python official library has the corresponding modules to support, directly download the call, on the basis of the base library to develop, greatly reduce the development cycle, Avoid making wheels repeatedly
    3. 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
    4. portability -because of its open source nature, Python has been ported to 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 on almost any system platform on the market without modification
    5. Scalability-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.
    6. embeddable --You can embed python in your C + + program to provide scripting capabilities to your program users.

Disadvantages:

    1. Slow, Python runs at a much slower pace than the C language and is slower than Java, so this is the main reason why so many so-called Daniel disdain to use Python, but in fact, this refers to the slow running speed in most cases the user is not directly aware of, must rely on testing tools to reflect , such as you use C a program to spend 0.01s, with Python is 0.1s, so C language directly than Python 10 times times faster, is very exaggerated, but you can not directly through the naked eye perception, because a normal person can perceive the smallest unit of time is 0.15-0.4s around, haha. In fact, in most cases python has been fully able to meet your requirements for the speed of the program, unless you want to write to the speed of the most demanding search engine, in this case, of course, it is recommended that you use C to achieve.
    2. code can not be encrypted , because Python is an explanatory language, its source code is stored in the form of a name, but I do not think this is a disadvantage, if your project requires that the source codes must be encrypted, then you should not use Python in the beginning to implement.
    3. threads are not able to take advantage of multi-CPU problems , which is one of the most common drawbacks of Python, the Gil, the Global Interpreter lock (interpreter lock), is the tool that the computer programming language interpreter uses to synchronize threads. So that at any moment only one thread is executing, the Python thread is the native thread of the operating system. On Linux for Pthread, on Windows for win thread, the execution of threads is fully dispatched by the operating system. A Python interpreter process has a main thread and the execution thread for multiple user programs. Multi-threaded parallel execution is prohibited even on multicore CPU platforms due to the existence of the Gil. A compromise solution to this problem is discussed in more detail later in the Threads and Processes section.

4) Python interpreter:

When we write the Python code, we get a text file that contains the Python code for the .py extension. To run the code, you need the Python interpreter to execute the .py file. The following are the base class common interpreters:

1.CPython

When we downloaded and installed Python 2.7 from the official Python website, we immediately got an official version of the interpreter: CPython. This interpreter was developed in C language, so called CPython. Running at the command line python is to start the CPython interpreter.

CPython is the most widely used Python interpreter. All the code for the tutorial is also executed under CPython.

2.IPython

Ipython is an interactive interpreter based on CPython, meaning that Ipython is only enhanced interactively, but the functionality and CPython of executing Python code are exactly the same. Like many domestic browsers although the appearance of different, but the kernel is actually called ie.

CPython >>> is used as a prompt, while Ipython is used In [ 序号 ]: as a prompt.

3.PyPy

PyPy is another Python interpreter whose goal is to perform speed. PyPy uses JIT technology to dynamically compile Python code (note that it is not interpreted), so it can significantly improve the execution speed of Python code.

Most python code can run under PyPy, but PyPy and CPython are somewhat different, which results in the same Python code being executed under both interpreters. If your code is to be executed under PyPy, you need to understand the differences between PyPy and CPython.

4.Jython

Jython is a Python interpreter running on the Java platform that compiles python code directly to Java bytecode execution.

5.IronPython

IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft. NET platform that compiles python code directly into. NET bytecode.

Python has a lot of interpreters, but the most widely used is cpython. If you want to interact with the Java or. NET platform, the best approach is not to use Jython or IronPython, but to interact via network tuning to ensure the independence of each program.

5) Python Installation:

Windows 1 、下载安装包      https: / / www.python.org / downloads / 2 、安装      默认安装路径:C:\python27 3 、配置环境变量      【右键计算机】 - - 》【属性】 - - 》【高级系统设置】 - - 》【高级】 - - 》【环境变量】 - - 》【在第二个内容框中找到 变量名为Path 的一行,双击】 - - > 【Python安装目录追加到变值值中,用 ; 分割】      如:原来的值;C:\python27,切记前面有分号

Linux, Mac

无需安装,原装Python环境

ps:如果自带,请更新至最新版本

Python Basics: Initial

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.