900 likes | 955 Views
Python A Comprehensive Programming Language. 胡崇偉 marr@citi.sinica.edu.tw Open Source Software Foundry. 自由軟體鑄造場. 營運網站以提供自由軟體專案進駐開發 提供系統技術與工具以協助軟體開發 研究開放源碼軟體授權條款與法律政策議題並提供諮詢 媒合促成以自由軟體為基礎的本地成功案例 報導國內外產業及社群新聞 進行人才培育及國際交流活動. Service and Resource. 專案管理. Service and Resource. 共同筆記. 版本管理.
E N D
PythonA ComprehensiveProgramming Language 胡崇偉 marr@citi.sinica.edu.tw Open Source Software Foundry
自由軟體鑄造場 • 營運網站以提供自由軟體專案進駐開發 • 提供系統技術與工具以協助軟體開發 • 研究開放源碼軟體授權條款與法律政策議題並提供諮詢 • 媒合促成以自由軟體為基礎的本地成功案例 • 報導國內外產業及社群新聞 • 進行人才培育及國際交流活動
Service and Resource 專案管理
Service and Resource 共同筆記 版本管理 檔案下載 專案管理 通信論壇 待辦事項 統計資訊
Service and Resource 資源目錄 共同筆記 人才資料 版本管理 檔案下載 授權條款 精靈 專案管理 電子報 通信論壇 待辦事項 研究報告 教學文件 統計資訊 推廣光碟
Pythonis a Dynamic Object-Oriented Programming Language
Run-Time Typing • Python's run time must work harder than Java's. • a + b = ? • inspect the objects a and b to find out their type, which is not known at compile time. • 7 + 11.0 • ‘Hello’ + ‘world’ • (1, 2, 3) + (4, 5, 6)
Interactive with Interpreter Edit Read-Eval-Print Loop Debug Compile Wait Deploy Read Print Eval
Built-in DataTypes • Number • String • List • Tuple • Dictionary 7, 11.0 ‘Hello World’ [7, 11, ‘store’] (7, 11, ‘shop’) {‘name’:’marr’, ‘home’:’taipei’} elements elements
Other Features • Cross Platform and Porting • Excellent Modules • Small • Efficient • Popular
Indexing and Slicing • myString = “I Love Python” • myString[0] == “I” • myString[-1] == “n” • myString[7:-2] == “Pyth”
Code Indenting • No explicit begin or end • No curly braces if age > 18: print “You are old enough.” else: print “You are too young.”
Function Example def myFunc(score): “”” document strings “”” import math math.sqrt(score) * 10
File Handling fileobj = open(“myfile”, “r”) lines = fileobj.readlines() for line in lines: print line
Socket Creation import socket s = socket.socket( socket.AF_INET, socket.SOCK_STREAM) s.connect( ("www.mysite.com", 80))
RestructuredText • http://docutils.sourceforge.net/ • Support Formats: HTML,XML,S5,LaTeX • rst2html < myRST.txt > myRST.html
Version Control • Mercurial
Plone … a CMS Built on Zope Written in Python
Download Installer • http://plone.org/products/plone
Filesystem Listing • Python • Zope • Plone • Packages/Products • Software Home • Instance Home
One Database, Many Instances HTTP Requests and Responses port 8081 port 8080 ZEO Client #1 ZEO Client #2 Instance #1 Instance #2 Data.fs
Tip for Trying Out -Different BrowsersforDifferent Users/Roles One for Admin, Another for Regular User