For many programmers, Python's big name should be earned. Most of the reviews of Python are different. Some even said Python is known for its slow operation. Here I am not going to comment on other people's faults, I just stand on a more objective angle to talk about Python this computer language. Python is an interpretative language and is an item of OpenSource. However, you can use it for commercial purposes. It can be released together in a commercial product CD. Of course, people can also get their installers or source code for free from www.python.org or opensource. Python was originally compiled on the Apple, but now he can run on the world's mainstream operating platform. He does not only have a Windows version. At the same time, there are also many platforms such as Linux, Unix, can be used in redHat9, and they are also installed as a language required. For Python's code type, it is basically divided into three types, which are byte code, binary code, and optimize code. Their suffix names are .py .pyc .pyo These code can run directly. There is no need to do any compilation or connection. On the use of these types of code, Python will make different types of different types. as follows:
#! / usr / bin / python # mypython.pyclass python: def __init __ (self): self.name = 'python' def Yourname (Self): print self.name
#! / usr / bin / python # main.pyimport mypythonpy = mypython.pythonpy.Yourname ()
At runtime, Python detects that there is a MyPython.pyc file in the current directory of main.py. If you don't import myPython.py and generate myPython.pyc for the next faster import. Prepare. In this way, there can be reduced a number of initialization times. Moreover, all this does not require user intervention, Python will be completed automatically. For its syntax, it is not recognized that his grammar is relatively simple in many other languages, and he excludes many cumbersome thinkings. as follows:
#! / usr / bin / pythona = 2003Print aa = 'Hello Python'Print AA = [2, 0, 0, 3] Print A [0]
The above code can be operated normally, the results are as follows:
2003HELLO PYTHON2
If it is C , at least the declaration of 3 group variables are required. And a variable for Python can be. Not only that, Python's management also has his uniqueness. The following is a comparison of Python and C for the same WHILE loop.
#! / usr / bin / python # python sourcea = 0WHILE (a <= 10): a = a 1 print 'the number is' aprint 'while is end'
// build by g or vc // C Source # include
int main ()
{
While (a <= 10)
{
A = a 1;
COUT << "The number is" <
<
}
COUT << "while is end";
Return 0;
}
For the comparison of the above code, it can be seen that the language such as C is to manage blocks in {}, and Python is reacly managed. Doing this does have his superiority. I believe that many programmers have leaks {} experience. If, if you use the compiler or explain, you can do very easy to add {}. However, if this is not the case, I think you will start roaming in a complex code. Because, you may tell you a wrong error message, this error location may be far away from you, which is far (probably 100,000 miles). Compared to this, the programmer has little to consider this problem with respect to the Python of the indent management. Secondly, the Python code in complex nested Python is divided into complex nesters. Comparison of Python and C in the following: #! / Usr / bin / python # python sourceclass python: def Hen: (self): print 'Hello' Def Count (n): in = 0 while (in <= N): in = in 1 Print In // Buile BY G or VC // C Source # includeint main ()
{
Class Python
{
PUBLIC:
Void Hello (Void)
{
COUT << "Hello" <
}
Void Count (INT N)
{
INT IN = 0;
While (IN <= n)
{
IN = IN 1;
Cout <
<
}
}
}
Return 0;
}
In a comparison, Python's code can be divided into its level, and although the code like C can be compiled successfully. However, for its future maintenance, there will be endless pain. At the same time, I almost missed when I just wrote C Source. Thus, it can be seen that the syntax of Python is simple. At the same time, his error capacity is also very strong. In general, Python's interpreter can accurately point out the location and cause of the error. As of the following code: #! / Usr / bin / pythonimport aa = 0print _A_A = B Running the code Python will throw the following error message: Traceback (MOST Recent Call Last): File "E: /Source.py", LINE 1, IN? IMPORT AIMPORTERROR: NO MODULE NAMPORT A TRACEBACK (MOST CALL LAST): File "E: / Source.py", LINE 3, IN? Print _anamerror: Name '_A' Is Not Defined Traceback (Most Recent Call Last: File "E: /Source.py", Line 4, in? _A = BNameError: Name 'b' is not defined can easily see the cause and location of the error. In this mechanism, when you debug complex programs, you don't have to worry about the problem that you cannot solve quickly. You just need to follow the incorrect prompt of Python, you can correct it. For Python applications, I personally probably divide them into three categories. The first class is software, this I don't think everyone should be very clear. Compared to the language such as C , Python's advantage is that his rapid development and code open. For Python, you can open a notepad or kwriter to write code, then save, running. This is true even if it is complex. This greatly reduces the development cycle and accelerates the development speed. Run with respect to traditional editing, compilation, connection. Python can have a lot of trouble. Three steps and two steps. Also because Python's concise code and short training time, it is very easy for software development and maintenance. Python's code interpretation, for the user, as long as Python is installed, the software for Python does not have to install Python. It is also possible to run directly to the software. For developers, the update and repair of products are easier. Perhaps you can simply repair the bug in the product as long as you use a user to browse a web page. This is grateful to Python's code reuse and flexible code management. For the error occurred at the reemploy, the developer can more Python comes with the wrong diagnosis. Moreover, there are many code bases about Python on the Internet, and these are free. For developed companies, it can save a considerable development fund. So, Python also has its own characteristics and market in the software market. The second category is a network class, with the rapid development of modern networks. Various web server scripts have emerged. Perl, PHP, ASP, etc. are all in place. Python can naturally be applied. Relative to PHP and ASP. Python enables all functions from the server software to the server script. Where Zope server software is a good example. For networks, Python has a set of modules to specifically for it.
Among them, there are Socket CGI and SocketServer, of course, Python can also be well supported with some large-scale databases. It can even be directly connected to them without passing through other intermediate plugins. Apply Python powerful support and Python's simple code. I believe you can write an excellent dynamic website in the break time. Third categories are education. Python was initially developed for education. Applying to education is of course a matter of reason. In programmers, if you ask their entry language, I think many people say that Basic said VB. In fact, Basic is not the best entry-level language. No matter whether Basic has no OOP programming ideas. Compile and connect when the code is running, although Basic and Python are interpreted languages. And its grammar is really unbearable. For example, if you want to add THEN to replace the {} in C , it is indeed a bit behind it. What is more important for learning programming is to learn how to use language to think. I understand how the program works, but also knows the basic programming ideas of some programs. All this is what Python can do. Python programming ideas and syntax are more like C and support class programming and code reuse. No matter what point of view, Python is the best language to let beginners understand how the programming is. And another function of Python - instantly run. It is also convenient for beginners to learn programming. After running the Python interpreter, you are running: >>> Print 'Hello Python'Hello Python This is important for beginners because they can use this mechanism to enter the code to see what the code does have. How is the program runs? This is important for in-depth programming. Moreover, this mechanism can be convenient to solve its questions for questions about beginners. This mechanism can make the initiator to get this idea of this idea faster. In terms of funds, if there is a small set of VisualBasic, it is a small use of some thousand yuan for the students to learn some programming ideas. Moreover, VisualBasic must run in Windows, and everyone has to spend more than 1,000 operating systems for each computer. This way, teaching agencies have a considerable amount of funds. Python is free, and many resources are free. And Python can also run on a free Linux system. Therefore, overall is smaller than the capital investment of using VB. Of course, anything has its bilateral. People are not often said, is the science a double-edged sword? Nice Python also has his lack of lack of foot. First, it is the definition of the function, the code is as follows: Def myfunction (Number): Return Number 10 This code can only know what type of data returned by myFunction when the function is defined, and Number does not know what data type. Only by in-depth code itself can understand all. Take a look at the following code: #! / Usr / bin / pythonclass myclass: def __init __ (self): self.name = 'myclass' Def Nothing (self): print 'end' It seems that this code is normal, Nothing method What Don't do it. But at runtime Python will prompt nothing to have errors and will affect the following code. So, I have to define this: #! / Usr / bin / pythonclass myclass: def __init __ (self): self.name = 'myclass' def Nothing (self): return print 'end' At the same time, I was initially mentioned Slowness is also a fact.