Part I General Application Topics 1
第 1部分 通用应用主题
Chapter 1 Regular Expressions 2
第 1章 正则表达式
1.1 Introduction/Motivation / 引言/动机 3
1.2 Special Symbols and Characters / 特殊的符号和字符 6
1.3 Regexes and Python / 正则表达式和Python语言 16
1.4 Some Regex Examples 一些正则表达式示例 36
1.5 A Longer Regex Example更长的正则表达式示例 41
1.6 Exercises / 练习 48
Chapter 2 Network Programming 53
第 2章 网络编程
2.1 Introduction / 前言 54
2.2 What Is Client/Server Architecture / 客户端/服务器网络编程 54
2.3 Sockets: Communication Endpoints / 套接字:通信端点 58
2.4 Network Programming in Python / Python中的网络编程 61
2.5 *The SocketServer Module / SocketServer模块 79
2.6 *Introduction to the Twisted Framework / *Twisted框架介绍 84
2.7 Related Modules / 相关模块 88
2.8 Exercises / 练习 89
Chapter 3 Internet Client Programming 94
第3章 Internet客户端编程
3.1 What Are Internet Clients / 什么是Internet客户端? 95
3.2 Transferring Files / 文件传输 96
3.3 Network News / 网络新闻 104
3.4 E-Mail / 电子邮件 114
3.5 Related Modules / 相关模块 146
3.6 Exercises / 练习 148
Chapter 4 Multithreaded Programming 156
第4章 多线程编程
4.1 Introduction/Motivation / 简介/动机 157
4.2 Threads and Processes / 线程和进程 158
4.3 Threads and Python / 线程和Python 160
4.4 The thread Module / thread模块 164
4.5 The threading Module / threading模块 169
4.6 Comparing Single vs. Multithreaded Execution /
单线程和多线程执行对比 180
4.7 Multithreading in Practice / 多线程实践 182
4.8 Producer-Consumer Problem and the Queue/queue Module /
生产者-消费者问题和Queue/queue模块 202
4.9 Alternative Considerations to Threads / 线程的替代方案 206
4.10 Related Modules / 相关模块 209
4.11 Exercises / 练习 210
Chapter 5 GUI Programming 213
第5章 GUI编程
5.1 Introduction / 简介 214
5.2 Tkinter and Python Programming / Tkinter和Python编程 216
5.3 Tkinter Examples / Tkinter示例 221
5.4 A Brief Tour of Other GUIs / 其他GUI简介 236
5.5 Related Modules and Other GUIs / 相关模块和其他GUI 247
5.6 Exercises / 练习 250
Chapter 6 Database Programming 253
第6章 数据库编程
6.1 Introduction / 简介 254
6.2 The Python DB-API / Python的DB-API 259
6.3 ORMs / 对象关系映射(ORM) 289
6.4 Non-Relational Databases / 非关系型数据库 309
6.5 Related References / 相关文献 316
6.6 Exercises / 练习 319
Chapter 7 *Programming Microsoft Office 324
第7章 *Microsoft Office编程
7.1 Introduction / 简介 325
7.2 COM Client Programming with Python / 使用Python进行
COM客户端编程 326
7.3 Introductory Examples / 入门示例 328
7.4 Intermediate Examples / 中级示例 338
7.5 Related Modules/Packages / 相关模块/包 357
7.6 Exercises / 练习 357
Chapter 8 Extending Python 364
第8章 扩展Python
8.1 Introduction/Motivation / 简介和动机 365
8.2 Extending Python by Writing Extensions /
编写Python扩展 368
8.3 Related Topics / 相关主题 384
8.4 Exercises / 练习 388
Part II Web Development 389
第 2部分 Web开发
Chapter 9 Web Clients and Servers 390
第9章 Web客户端和服务器
9.1 Introduction / 简介 391
9.2 Python Web Client Tools / Python Web客户端工具 396
9.3 Web Clients / Web客户端 410
9.4 Web (HTTP) Servers / Web(HTTP)服务器 428
9.5 Related Modules / 相关模块 433
9.6 Exercises / Exercises 436
Chapter 10 Web Programming: CGI and WSGI 441
第 10章 Web编程:CGI和WSGI
10.1 Introduction / 简介 442
10.2 Helping Web Servers Process Client Data / 帮助Web服务
器处理客户端数据 442
10.3 Building CGI Applications / 建立CGI应用程序 446
10.4 Using Unicode with CGI / 在CGI中使用Unicode 464
10.5 Advanced CGI / 高 级CGI 466
10.6 Introduction to WSGI / WSGI简介 478
10.7 Real-World Web Development / 真实世界的Web开发 487
10.8 Related Modules / 相关模块 488
10.9 Exercises / 练习 490
Chapter 11 Web Frameworks: Django 493
第 11章 Web框架:Django
11.1 Introduction / 简介 494
11.2 Web Frameworks / Web框架 494
11.3 Introduction to Django / Django简介 496
11.4 Projects and Apps / 项目和应用 501
11.5 Your “Hello World” Application (A Blog) / “Hello World”
应用(一个博客) 507
11.6 Creating a Model to Add Database Service / 创建一个
Model来添加数据库服务 509
11.7 The Python Application Shell / Python Application Shell 514
11.8 The Django Administration App / Django管理应用 518
11.9 Creating the Blog’s User Interface /
创建Blog的用户界面 527
11.10 Improving the Output / 改进输出 537
11.11 Working with User Input / 处理用户输入 542
11.12 Forms and Model Forms / 表单和模型表单 546
11.13 More About Views / 视图进阶 551
11.14 *Look-and-Feel Improvements / *改善外观 553
11.15 *Unit Testing / *单元测试 554
11.16 *An Intermediate Django App: The TweetApprover /
中级Django应用:TweetApprover 564
11.17 Resources / 资源 597
11.18 Conclusion / 总结 597
11.19 Exercises / 练习 598
Chapter 12 Cloud Computing: Google App Engine 604
第 12章 云计算:Google App Engine
12.1 Introduction / 简介 605
12.2 What Is Cloud Computing / 什么是云计算? 605
12.3 The Sandbox and the App Engine SDK /
沙盒和App Engine SDK 612
12.4 Choosing an App Engine Framework /
选择一个App Engine框架 617
12.5 Python 2.7 Support / Python 2.7支持 626
12.6 Comparisons to Django / 与Django比较 628
12.7 Morphing “Hello World” into a Simple Blog /
将“Hello World”改成一个简单的博客 631
12.8 Adding Memcache Service / 添加Memcache服务 647
12.9 Static Files / 静态文件 651
12.10 Adding Users Service / 添加用户服务 652
12.11 Remote API Shell / 远程API Shell 654
12.12 Lightning Round (with Python Code) /
问与答(Python实现) 656
12.13 Sending Instant Messages by Using XMPP /
使用XMPP发送即时消息 660
12.14 Processing Images / 处理图片 662
12.15 Task Queues (Unscheduled Tasks) /
任务队列(非定期任务) 663
12.16 Profiling with Appstats / 使用Appstats进行分析 670
12.17 The URLfetch Service / URLfetch服务 672
12.18 Lightning Round (without Python Code) /
问与答(没有Python代码) 673
12.19 Vendor Lock-In / 厂商锁定 675
12.20 Resources / 资源 676
12.21 Conclusion / 总结 679
12.22 Exercises / 练习 680
Chapter 13 Web Services 684
第 13章 Web服务
13.1 Introduction / 简介 685
13.2 The Yahoo! Finance Stock Quote Server /
Yahoo!金融股票报价服务器 685
13.3 Microblogging with Twitter / Twitter微博 690
13.4 Exercises / 练习 707
Part III Supplemental/Experimental 713
第3部分 补充/实验章节
Chapter 14 Text Processing 714
第 14章 文本处理
14.1 Comma-Separated Values / 逗号分隔的值(CSV) 715
14.2 JavaScript Object Notation / JavaScript对象表示法(JSON) 719
14.3 Extensible Markup Language / 可扩展标记语言 724
14.4 References / 参考资料 738
14.5 Related Modules / 相关模块 740
14.6 Exercises / 练习 740
Chapter 15 Miscellaneous 743
第 15章 其他内容
15.1 Jython / Jython 744
15.2 Google+ / Google+ 748
15.3 Exercises / 练习 759
Appendix A Answers to Selected Exercises 763
附录A 部分练习参考答案
Appendix B Reference Tables 768
附录B 参考表
Appendix C Python 3: The Evolution of a Programming Language 798
附录C Python 3:一种编程语言的进化产物
Appendix D Python 3 Migration with 2.6+ 807
附录D 利用Python 2.6+进行Python 3迁移