The python programing language
2014-04-08 17:41
155 查看
Python is an example of high-level language. As you might infer from the name “high-level language”, there are also low-level languages, sometimes referred to as “machine languages” or “assembly languages”. Loosely speaking, computers can only execute programs written in low-level languages. So programs written in a high-level language have to be processed before they can run. This extra processing takes some time, which is a small disadvantage of high-level languages.
But the advantages are enormous. First, it is much easier to program in a high-level language. Programs written in a high-level language take less time to write, they are shorter and easier to read, and they are more likely to be correct. Second, high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.
Due to these advantages, almost all programs are written in high-level languages. Low-level languages are used only for a few specialized applications.
Two kinds of programs process high-level languages into low-level languages: interpreters and compilers. And interpreter reads a high-level program and executes it, meaning that it does what the programs says. It processes the program a little at a time, alternately reading lines and performing computations.
![](http://images.cnitblog.com/i/399595/201404/081739108095855.png)
A compiler reads the program and translates it completely before it starts running. In this case, the high-level program is called the source code, and the translated program is called the object code or the executable. Once a program is compiled, you can execute it repeatedly without further translation.
![](http://images.cnitblog.com/i/399595/201404/081740093094783.png)
Python is considered an interpreter language because python is executed by an interpreter. There are two ways to use the interpreter: interactive mode and script mode. By convention, python scripts have names that end with .py.
Working in interactive mode is convenient for testing small pieces of code because you can type and execute them immediately. But for anything more than a few lines, you should save your code as a script so you can modify and execute it in future.
From Thinking in Python
But the advantages are enormous. First, it is much easier to program in a high-level language. Programs written in a high-level language take less time to write, they are shorter and easier to read, and they are more likely to be correct. Second, high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.
Due to these advantages, almost all programs are written in high-level languages. Low-level languages are used only for a few specialized applications.
Two kinds of programs process high-level languages into low-level languages: interpreters and compilers. And interpreter reads a high-level program and executes it, meaning that it does what the programs says. It processes the program a little at a time, alternately reading lines and performing computations.
![](http://images.cnitblog.com/i/399595/201404/081739108095855.png)
A compiler reads the program and translates it completely before it starts running. In this case, the high-level program is called the source code, and the translated program is called the object code or the executable. Once a program is compiled, you can execute it repeatedly without further translation.
![](http://images.cnitblog.com/i/399595/201404/081740093094783.png)
Python is considered an interpreter language because python is executed by an interpreter. There are two ways to use the interpreter: interactive mode and script mode. By convention, python scripts have names that end with .py.
Working in interactive mode is convenient for testing small pieces of code because you can type and execute them immediately. But for anything more than a few lines, you should save your code as a script so you can modify and execute it in future.
From Thinking in Python
相关文章推荐
- The Python Standard Library » 31. Python Language Services
- The C programing language 第四章,课后题
- 【2014Esri开发者大会精彩看点】Python is the language of ArcGIS
- the c programing language 1-23 删除注释
- the c programing language 1-22 较长输入行折成短些的多行,非缓冲方式实现
- 重新夯实基础,the c programingn language 再读笔记之函数与程序结构
- c++程序设计语言(the c++ programing language) 目录
- 重新夯实基础,the c programingn language 再读笔记
- The C programing language 第三章课后题
- the c programing language 练习1-21 将空格字符替换为最少数量的制表符和空格
- The C Programming Language Example and Python Implemented
- The C programing language K&R 笔记
- 重新夯实基础,the c programingn language 再读笔记之类型、运算符与表达式
- the c programing language chap5 : pointer and array
- The Python Programming Language Notes
- The C programing language 第一章
- Hey, ready for the script language "Python"
- Gotchas in the C++ programing language
- 官网PYthon语言参考手册The Python Language Reference