前言
python哲学理念
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
1.python可定义为面向对象的脚本语言
2.python的最大缺点是执行速度不够快
3.python可以被应用于以下几个方面:系统编程,用户图形接口,Internet脚本,组件集成,数据库编程,快速原型,科学计算,游戏,图像,人工智能,XML,机器人等。
4.python的优点:面向对象,免费,可移植,功能强大,可混合,易学易用。
Python是如何运行的
Python解释器
Python解释器一般是C实现的,也有用Java实现的Jython。
Python文件的执行
1.Python的传统运行执行模式:源代码(.py)→字节码(.pyc)→PVM
录入的源代码转换为字节码,之后字节码在Python虚拟机(PVM)中运行。代码被自动编译,之后再解释。
2.执行优化工具:
- Psyco实时编译器:Psyco是一个PVM的增强工具,将部分程序的字节码转换成底层的真正的二进制机器代码
- Shedskin C++转换器