Python介绍
limodou
limodou@gmail.com
一、开场白
[any material that should appear in print but not on the slide]
2.0 Python T-Shirt
[any material that should appear in print but not on the slide]
2.1 什么是Python
Python是一种语法简洁优美的,面向对象的,内置高级数据结构,支持模块和包,支持多种平台,可扩展的解释型通用编程语言。
[any material that should appear in print but not on the slide]
2.2 Python怎么读
[any material that should appear in print but not on the slide]
2.3 学习Python的好处
- 掌握一种新的编程语言,一种新技能
- 体会动态语言的妙处
- 体验快速开发的快感
- 让你实现快速学习的梦想
[any material that should appear in print but not on the slide]
二、Python的历史
创始人Guido van Rossum,原在荷兰,现在美国。
Guido 写的一些PPT http://www.python.org/doc/essays/ppt/
[any material that should appear in print but not on the slide]
2.1 创建
Python的创始人为Guido van Rossum。1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本解释程序,做为ABC语言的一种继承。之所以选中Python作为程序的名字,是因为他是一个Monty 大蟒蛇飞行马戏团的爱好者。
[any material that should appear in print but not on the slide]
2.2 ABC
ABC是由Guido参加设计的一种教学语言。就Guido本人看来,ABC这种语言非常优美和强大,是专门为非专业程序员设计的。但是ABC语言并没有成功,究其原因,Guido认为是非开放造成的。Guido决心在Python中避免这一错误(的确如此,Python与其它的语言如C,C++和Java结合的非常好)。同时,他还想实现在ABC中闪现过但未曾实现的东西。
[any material that should appear in print but not on the slide]
2.3 第一个Python
就这样,Python在Guido手中诞生了。实际上,第一个实现是在Mac机上。可以说,Python是从ABC发展起来,主要受到了Modula-3(另一种相当优美且强大的语言,为小型团体所设计的)的影响。并且结合了Unix Shell和C的习惯。
[any material that should appear in print but not on the slide]
2.4 目前
目前Python已经发展到 2.5
可以在众多的平台上运行
Python的社区非常活跃,项目也非常多
[any material that should appear in print but not on the slide]
2.5 Python.org的访问量
- Feb 2004 python.org traffic:
793K visits from 421K sites (1.0 TB)
- Feb 2005 python.org traffic:
1023K visits from 473K sites (1.3 TB)
- Growth in one year:
visits +29%, originating sites +12%, data +30%
- and Feb 2004 had a leap day :-)
[any material that should appear in print but not on the slide]
2.6 在soureforge上的前10种语言
- 15934 C++
- 15621 Java
- 15260 C
- 11427 PHP
- 5974 Perl
- 4200 Python
- 2597 C#
- 2488 JavaScript
- 2127 Visual Basic
- 1841 Delphi/Kylix
[any material that should appear in print but not on the slide]
三、Python的应用领域
- GUI开发,网络开发
- 图形开发,文档处理
- 游戏开发,Web开发
- 科学计算,移动开发
- 嵌入开发,数据库开发
- ...
[any material that should appear in print but not on the slide]
3.1 GUI
- tcl/tk
- wxPython
- pygtk
- pyqt
- pywin32
- ctypes
- pyswt
[any material that should appear in print but not on the slide]
3.2 网络
- socket编程
- 高级网络模块
- socketserver,httpserver
- email, ftp, telnet, http
- twisted
- jabber
- python-qq
[any material that should appear in print but not on the slide]
3.3 图形
- PIL(Python Imaging Library)
- 3d
- blender
- Panda,Disney开发的
- 2d, plot
- matplotlib
- pycairo
[any material that should appear in print but not on the slide]
3.4 文档
- reStructuredText 结构化文本
- epydoc 生成Python API文档
- reportlab 生成PDF文件
- moinmoin wiki系统,共同写作
[any material that should appear in print but not on the slide]
3.5 游戏
[any material that should appear in print but not on the slide]
3.6 Web开发
- mod_python
- zope/plone
- karrigell
- cherrypy
- django
- quixote
- snakelets
[any material that should appear in print but not on the slide]
3.7 科学计算
[any material that should appear in print but not on the slide]
3.8 移动开发
- 掌上电脑上的Python
- 手机上的Python Python for s60
[any material that should appear in print but not on the slide]
3.9 嵌入开发
- 在应用中调用Python库和程序
- p4d(python for delphi)
[any material that should appear in print but not on the slide]
3.10 数据库开发
- 标准DB-API接口
- 支持众多数据库
- sqlite
[any material that should appear in print but not on the slide]
四、Python的影响
- Java平台
- Jython
- groovy
- .net平台
- python.net
- IronPython
- boo
[any material that should appear in print but not on the slide]
五、Python的特性
- 运行方式
- 动态绑定
- 面向对象
- 模块和包
- 语言扩展
- 有趣的语法
- 其它
[any material that should appear in print but not on the slide]
6.1 运行方式
[any material that should appear in print but not on the slide]
6.2 动态绑定
[any material that should appear in print but not on the slide]
6.3 面向对象
- 一切皆对象
- 多重继承
- 异常处理
- 垃圾自动回收
- New Style Class和Classic Class
- property、自省、setattr/getattr
- 操作符/函数重载
- 元类(Metaclass)编程
[any material that should appear in print but not on the slide]
6.4 模块和包
- 将数据与类作为供它人使用的模块
- 对于多文件可以封装成包
- 有专用的打包工具
- 有标准的安装过程
python setup.py install
[any material that should appear in print but not on the slide]
6.5 语言的扩展
- C,C++扩展
- swig, sip
- pyrex
- ctypes
- Boost:Python
[any material that should appear in print but not on the slide]
6.6 Unicode的支持
[any material that should appear in print but not on the slide]
6.7 有趣的语法
- 缩排
- 高级数据结构
- 变量交换
- 参数缺省值,不定参数与关键字参数
- list comprehension
- _, __变量
- ...
[any material that should appear in print but not on the slide]
6.8 其它
- 自动编译成字节文件
- 导入时顶层代码自动执行
- 强大的自省能力
- 对象序列化
- 测试框架
- 多线程
- ...
[any material that should appear in print but not on the slide]
六、Python的哲学
- Python的哲学--Pythonic
- import this
[any material that should appear in print but not on the slide]
6.1 Zen of Python
禅
优美胜过丑陋 明确胜过含蓄
简单胜过复杂 复杂胜过难懂
扁平胜过嵌套 稀疏胜过密集
易读亦有价
尽管实用会击败纯洁 特例也不能特殊到打破规则
除非明确地使其沉默 错误永远不应默默地溜掉
面对着不确定,要拒绝猜测的诱惑
应该有一个--宁肯只有一个--明显的实现方法
也许这个方法开始不是很明显,除非你是荷兰人
尽管不做通常好过立刻做 但现在做也要胜过不去做
如果实现很难解释,那它就是一个坏想法
如果实现容易解释,那它可能就是一个好想法
名字空间是一个响亮的出色想法--就让我们多用用它们
[any material that should appear in print but not on the slide]
6.2 开源精神
[any material that should appear in print but not on the slide]
七、如何学习Python
- 实践是检验真理的唯一标准
- 学习开源精神
- 在工作和学习中主动应用
- 订阅邮件列表与人交流
- 参与项目
- 多看源代码
- 勤写作、勤积累
[any material that should appear in print but not on the slide]
八、Python在中国的发展
[any material that should appear in print but not on the slide]
8.1 CPUG的简介
- 成立于2005/07/30
- 整合了python.cn,啄木鸟社区的资源
- 提供门户(python.cn),邮件列表,wiki,trac,planet资源
- python.cn用于讨论技术, cpug用于社区建设
- 截止到目前邮件列表有1600多人
- 讨论气氛很热烈
- CPUG每月活动一次,由新浪提供资源,已经组织了11次了
- 需要志愿者为社区做贡献
[any material that should appear in print but not on the slide]
九、Python的一些资源
[any material that should appear in print but not on the slide]
十、问题时间
谢谢!
[any material that should appear in print but not on the slide]