51
Python Intro @fantasy614 [email protected] 研究院北415 哈工大(威海)开源技术沙龙第一期

开源沙龙第一期 Python intro

Embed Size (px)

Citation preview

Page 1: 开源沙龙第一期 Python intro

Python Intro@fantasy614

[email protected]研究院北415

哈工大(威海)开源技术沙龙第一期

Page 2: 开源沙龙第一期 Python intro

一切资料来自网络互动挖掘一切想法来自日常学习工作一切体悟种沟通交流一切知识来自社区分享印证一切经验来自个人失败体验 ......

免责声明

非原创,山寨Zoom.Quiet

Page 3: 开源沙龙第一期 Python intro
Page 4: 开源沙龙第一期 Python intro

从大牛说起

Page 5: 开源沙龙第一期 Python intro

Bruce Eckel

Page 6: 开源沙龙第一期 Python intro

Page 3

Bruce Eckel

Page 7: 开源沙龙第一期 Python intro

Why I Love Python© 2001 Bruce EckelMindView, Inc.Training & Consulting5343 Valle VistaLa Mesa, CA [email protected]://www.mindview.net/pub/eckel/LovePython.zip

Page 8: 开源沙龙第一期 Python intro

另外一个例子

Page 9: 开源沙龙第一期 Python intro

请在20秒钟内用你最熟悉的语言在心中构建出下题的所有源代码(非思路)

从一个文本文件中读取所有字符串,然后将“windows”替换成“linux”,保存在另外一个文件中

Page 10: 开源沙龙第一期 Python intro

如此冗长,你的青春浪费在查找各种API手册上面了

Page 11: 开源沙龙第一期 Python intro

infile = file("infile","r")outfile = file("outfile", "w") for line in infile.readlines(): newline=line.replace("windows","linux") outfile.write(newline)

Python的一个实现版本。。。

Page 12: 开源沙龙第一期 Python intro

infile = file("infile.txt","r")outfile = file("outfile.txt", "w") outfile.write(infile.read().replace("windows","linux"))

Or,Even...

Page 13: 开源沙龙第一期 Python intro

So, what is pyton?

Page 14: 开源沙龙第一期 Python intro

what is python

Page 15: 开源沙龙第一期 Python intro

And,why python?

Page 16: 开源沙龙第一期 Python intro

Why Python?

简单易学Hello World: 1分钟小工具脚本: 1下午实用程序: 1周 做个豆瓣: 3个月(@hongqn,豆瓣首席架构师)

Page 17: 开源沙龙第一期 Python intro

Why Python?资源丰富

Battery Included: 标准库内置200+模块PyPI: 9613 packages currently 网络/数据库/桌面/游戏/科学计算/安全/文本处理/...easily extensible

Page 18: 开源沙龙第一期 Python intro

Why Python?

内置高级数据类型和操作,list,dict,tuple,etc跨平台,Linux/Unix,Win,Mac支持广泛,特别是google的服务胶水,可以和C,C++,java,c#等混合编程Open Source,没有铜臭味内置GC,无需程序员做内存管理

Page 19: 开源沙龙第一期 Python intro

Who use python?

Page 20: 开源沙龙第一期 Python intro

Who use pythonGoogleYoutubeDoubanDropbox金山, 网易,新浪BitTorrentNASAPlurk

Page 21: 开源沙龙第一期 Python intro

What python can't do?

Page 22: 开源沙龙第一期 Python intro

Sorry。。。

我只能告诉你python不适合于做什么驱动程序以及对效率要求极高的程序(如科学运算)

Page 23: 开源沙龙第一期 Python intro

Python 应用

Web and Internet Development (django,web.py,zope,etc)Database Access (odbc,st)Desktop GUIs (QT,gtk,wx,MFC)Scientific and Numeric Education Network Programming (Socket,Twisted)Software Development Game and 3D Graphics (pygame)

http://www.python.org/about/apps/

Page 24: 开源沙龙第一期 Python intro

Python compared to other languages

Page 25: 开源沙龙第一期 Python intro

一般的说法是这样

Page 26: 开源沙龙第一期 Python intro

一般说法

Perl 擅长做服务器的管理,因为它的字串处理功能特别强大,同时有全面的编程接口和操作系统相连。自己用没问题,就是不懂人家在写什么。

PHP 擅长于网页,因为它可以嵌入在 HTML 文件中并支援各类资料库。但一离开网页就左支右绌。

Tcl/Tk 基本变数形态只有文字串,每次算术都是从文字变数字再变文字,鸣,没什么好提的了吧。

Java 太伟大了,我可不想每次开始写程式时都幻想要完成一个跨企业的解决方案,引入几十个标头档,写完了才明白原来我只需它读一个用户指定的文件,画两条直线就行了。唉,落差太大。

Ruby 太新了,要正式应用是将来的事。

Page 27: 开源沙龙第一期 Python intro

但是还是得看牛人咋说的

Page 28: 开源沙龙第一期 Python intro

Interview with Bruce Eckel by Clay Shannon

Compare and contrast Java, C++, Delphi, Python, and C#--what are the advantages/disadvantages of each?

Saving the best for last, I've said in numerous places that Python is my favorite language, and this is because I'm most productive in that language. I can get so much more done in Python than in any other language I've encountered that it's very hard for me to use those other languages, because to do so means throwing away time. Also, I've found the Python community to be my favorite group of language people; I can't figure out how or why this is the case, but it retains the gentleness and enthusiasm that I most value in my interactions with a language community. I look forward to when I finally get my plate cleared enough that I can continue working on "Thinking in Python."

http://edn.embarcadero.com/article/30139

Page 29: 开源沙龙第一期 Python intro

python 之道

Page 30: 开源沙龙第一期 Python intro

The zen of python

There is only one way to do it. 要做好一件事,一种方法就够Everything is object. 万物皆对象Readability counts. 可读性优先Explicit is better than implicit. 明显胜于隐晦 Simple is better than complex. 简单胜于复杂

Page 31: 开源沙龙第一期 Python intro

闲扯关于python 其它实现

Page 32: 开源沙龙第一期 Python intro

Python的其它实现

CPython(Classic Python,也就是原始的经典Python实现,需要区别于其他实现的时候才以CPython称呼;或解作C语言实现的Python)

Jython(原名JPython;Java语言实现的Python,现已正式发布)

PyPy(使用Python语言写的Python)

IronPython(面向.NET和ECMA CLI的Python实现)

周蟒(支持繁简中文的Python语言)

Page 33: 开源沙龙第一期 Python intro

Django框架介绍

Page 34: 开源沙龙第一期 Python intro

Stackoverflow 上的红人Django

Page 35: 开源沙龙第一期 Python intro

Django的优点

URL映射MVCAdmin界面方便的ORM功能强大的模板统一的管理中心Pythonic,学习成本低

Page 36: 开源沙龙第一期 Python intro

Xmlrpc介绍

Server: from SimpleXMLRPCServer import SimpleXMLRPCServer def foo(): return "Hello world!" server = SimpleXMLRPCServer( ("localhost", 8000) ) server.register_function(foo) server.serve_forever()

Client: from xmlrpclib import ServerProxy server = ServerProxy("http://localhost:8000") print server.foo()

Page 37: 开源沙龙第一期 Python intro

Web Server• python -m SimpleHTTPServer 内部网络文件共享,just so simple

Page 38: 开源沙龙第一期 Python intro

Python的IDE

Page 40: 开源沙龙第一期 Python intro

有相应插件的通用IDE软件(使用难度往往较大):

eclipse + pydev插件:稳定性欠佳

emacs + 插件

Vim + 插件

Visual Studio .NET 2003 + VisualPython:仅适用Windows,已停止维护,功能较差

SlickEditTextMate

Python的IDE

Page 41: 开源沙龙第一期 Python intro

Python社区

Page 42: 开源沙龙第一期 Python intro

啄木鸟社区 http://wiki.woodpecker.org.cn/moin/首页

Page 43: 开源沙龙第一期 Python intro

Google Groups http://groups.google.com/

Page 44: 开源沙龙第一期 Python intro

书目

Page 45: 开源沙龙第一期 Python intro
Page 46: 开源沙龙第一期 Python intro
Page 47: 开源沙龙第一期 Python intro
Page 48: 开源沙龙第一期 Python intro
Page 49: 开源沙龙第一期 Python intro
Page 50: 开源沙龙第一期 Python intro

一些URL

http://www.python.orghttp://wiki.woodpecker.org.cn/moin/首页http://stackoverflow.com/http://www.djangoproject.com/http://www.mindview.net/http://groups.google.com/http://www.slideshare.net/http://edn.embarcadero.com/article/30139 http://www.wikipedia.org/http://www.google.com/

Page 51: 开源沙龙第一期 Python intro

Life is short,you need python

Thanks !