开源沙龙第一期 python intro

Post on 14-Jul-2015

551 Views

Category:

Documents

13 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Python Intro@fantasy614

fantasy614@gmail.com研究院北415

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

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

免责声明

非原创,山寨Zoom.Quiet

从大牛说起

Bruce Eckel

Page 3

Bruce Eckel

Why I Love Python© 2001 Bruce EckelMindView, Inc.Training & Consulting5343 Valle VistaLa Mesa, CA 91941Bruce@EckelObjects.comwww.MindView.netftp://www.mindview.net/pub/eckel/LovePython.zip

另外一个例子

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

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

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

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

Python的一个实现版本。。。

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

Or,Even...

So, what is pyton?

what is python

And,why python?

Why Python?

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

Why Python?资源丰富

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

Why Python?

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

Who use python?

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

What python can't do?

Sorry。。。

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

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/

Python compared to other languages

一般的说法是这样

一般说法

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

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

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

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

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

但是还是得看牛人咋说的

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

python 之道

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. 简单胜于复杂

闲扯关于python 其它实现

Python的其它实现

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

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

PyPy(使用Python语言写的Python)

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

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

Django框架介绍

Stackoverflow 上的红人Django

Django的优点

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

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()

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

Python的IDE

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

eclipse + pydev插件:稳定性欠佳

emacs + 插件

Vim + 插件

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

SlickEditTextMate

Python的IDE

Python社区

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

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

书目

一些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/

Life is short,you need python

Thanks !

top related