没有合适的资源?快使用搜索试试~ 我知道了~
首页dive into python
资源详情
资源评论
资源推荐
Table of Contents
Dive Into Python...............................................................................................................................................................1
Chapter 1. Installing Python...........................................................................................................................................2
1.1. Which Python is right for you?......................................................................................................................2
1.2. Python on Windows.......................................................................................................................................2
1.3. Python on Mac OS X.....................................................................................................................................3
1.4. Python on Mac OS 9......................................................................................................................................5
1.5. Python on RedHat Linux...............................................................................................................................5
1.6. Python on Debian GNU/Linux......................................................................................................................6
1.7. Python Installation from Source....................................................................................................................6
1.8. The Interactive Shell......................................................................................................................................7
1.9. Summary........................................................................................................................................................8
Chapter 2. Your First Python Program.........................................................................................................................9
2.1. Diving in........................................................................................................................................................9
2.2. Declaring Functions.......................................................................................................................................9
2.3. Documenting Functions...............................................................................................................................10
2.4. Everything Is an Object...............................................................................................................................11
2.5. Indenting Code.............................................................................................................................................13
2.6. Testing Modules...........................................................................................................................................14
Chapter 3. Native Datatypes.........................................................................................................................................15
3.1. Introducing Dictionaries..............................................................................................................................15
3.2. Introducing Lists..........................................................................................................................................17
3.3. Introducing Tuples.......................................................................................................................................22
3.4. Declaring variables......................................................................................................................................23
3.5. Formatting Strings.......................................................................................................................................25
3.6. Mapping Lists..............................................................................................................................................26
3.7. Joining Lists and Splitting Strings...............................................................................................................28
3.8. Summary......................................................................................................................................................29
Chapter 4. The Power Of Introspection.......................................................................................................................31
4.1. Diving In......................................................................................................................................................31
4.2. Using Optional and Named Arguments.......................................................................................................32
4.3. Using type, str, dir, and Other Built-In Functions.......................................................................................33
4.4. Getting Object References With getattr.......................................................................................................36
4.5. Filtering Lists...............................................................................................................................................38
4.6. The Peculiar Nature of and and or...............................................................................................................39
4.7. Using lambda Functions..............................................................................................................................41
4.8. Putting It All Together.................................................................................................................................43
4.9. Summary......................................................................................................................................................45
Chapter 5. Objects and Object-Orientation................................................................................................................47
5.1. Diving In......................................................................................................................................................47
5.2. Importing Modules Using from module import...........................................................................................49
5.3. Defining Classes..........................................................................................................................................50
5.4. Instantiating Classes.....................................................................................................................................53
5.5. Exploring UserDict: A Wrapper Class........................................................................................................54
5.6. Special Class Methods.................................................................................................................................56
5.7. Advanced Special Class Methods................................................................................................................59
Dive Into Python i
Table of Contents
Chapter 5. Objects and Object-Orientation
5.8. Introducing Class Attributes........................................................................................................................60
5.9. Private Functions.........................................................................................................................................62
5.10. Summary....................................................................................................................................................63
Chapter 6. Exceptions and File Handling....................................................................................................................64
6.1. Handling Exceptions....................................................................................................................................64
6.2. Working with File Objects...........................................................................................................................66
6.3. Iterating with for Loops...............................................................................................................................70
6.4. Using sys.modules.......................................................................................................................................72
6.5. Working with Directories............................................................................................................................74
6.6. Putting It All Together.................................................................................................................................77
6.7. Summary......................................................................................................................................................78
Chapter 7. Regular Expressions...................................................................................................................................80
7.1. Diving In......................................................................................................................................................80
7.2. Case Study: Street Addresses.......................................................................................................................80
7.3. Case Study: Roman Numerals.....................................................................................................................82
7.4. Using the {n,m} Syntax...............................................................................................................................84
7.5. Verbose Regular Expressions......................................................................................................................87
7.6. Case study: Parsing Phone Numbers...........................................................................................................88
7.7. Summary......................................................................................................................................................92
Chapter 8. HTML Processing.......................................................................................................................................93
8.1. Diving in......................................................................................................................................................93
8.2. Introducing sgmllib.py.................................................................................................................................97
8.3. Extracting data from HTML documents......................................................................................................99
8.4. Introducing BaseHTMLProcessor.py........................................................................................................101
8.5. locals and globals.......................................................................................................................................103
8.6. Dictionary-based string formatting............................................................................................................106
8.7. Quoting attribute values.............................................................................................................................107
8.8. Introducing dialect.py................................................................................................................................108
8.9. Putting it all together..................................................................................................................................110
8.10. Summary..................................................................................................................................................112
Chapter 9. XML Processing........................................................................................................................................114
9.1. Diving in....................................................................................................................................................114
9.2. Packages.....................................................................................................................................................120
9.3. Parsing XML..............................................................................................................................................122
9.4. Unicode......................................................................................................................................................124
9.5. Searching for elements...............................................................................................................................128
9.6. Accessing element attributes......................................................................................................................129
9.7. Segue..........................................................................................................................................................131
Chapter 10. Scripts and Streams................................................................................................................................132
10.1. Abstracting input sources.........................................................................................................................132
10.2. Standard input, output, and error.............................................................................................................135
10.3. Caching node lookups..............................................................................................................................139
10.4. Finding direct children of a node.............................................................................................................140
10.5. Creating separate handlers by node type.................................................................................................140
Dive Into Python ii
Table of Contents
Chapter 10. Scripts and Streams
10.6. Handling command-line arguments.........................................................................................................142
10.7. Putting it all together................................................................................................................................145
10.8. Summary..................................................................................................................................................147
Chapter 11. HTTP Web Services................................................................................................................................148
11.1. Diving in..................................................................................................................................................148
11.2. How not to fetch data over HTTP............................................................................................................150
11.3. Features of HTTP.....................................................................................................................................151
11.4. Debugging HTTP web services...............................................................................................................152
11.5. Setting the User-Agent.............................................................................................................................153
11.6. Handling Last-Modified and ETag..........................................................................................................155
11.7. Handling redirects....................................................................................................................................158
11.8. Handling compressed data.......................................................................................................................161
11.9. Putting it all together................................................................................................................................164
11.10. Summary................................................................................................................................................166
Chapter 12. SOAP Web Services................................................................................................................................167
12.1. Diving In..................................................................................................................................................167
12.2. Installing the SOAP Libraries..................................................................................................................168
12.3. First Steps with SOAP.............................................................................................................................170
12.4. Debugging SOAP Web Services.............................................................................................................171
12.5. Introducing WSDL...................................................................................................................................172
12.6. Introspecting SOAP Web Services with WSDL......................................................................................173
12.7. Searching Google.....................................................................................................................................175
12.8. Troubleshooting SOAP Web Services.....................................................................................................178
12.9. Summary..................................................................................................................................................181
Chapter 13. Unit Testing.............................................................................................................................................182
13.1. Introduction to Roman numerals.............................................................................................................182
13.2. Diving in..................................................................................................................................................183
13.3. Introducing romantest.py.........................................................................................................................183
13.4. Testing for success...................................................................................................................................186
13.5. Testing for failure....................................................................................................................................188
13.6. Testing for sanity.....................................................................................................................................189
Chapter 14. Test-First Programming.........................................................................................................................192
14.1. roman.py, stage 1.....................................................................................................................................192
14.2. roman.py, stage 2.....................................................................................................................................195
14.3. roman.py, stage 3.....................................................................................................................................198
14.4. roman.py, stage 4.....................................................................................................................................201
14.5. roman.py, stage 5.....................................................................................................................................204
Chapter 15. Refactoring..............................................................................................................................................207
15.1. Handling bugs..........................................................................................................................................207
15.2. Handling changing requirements.............................................................................................................209
15.3. Refactoring...............................................................................................................................................215
15.4. Postscript..................................................................................................................................................218
15.5. Summary..................................................................................................................................................220
Dive Into Python iii
Table of Contents
Chapter 16. Functional Programming.......................................................................................................................222
16.1. Diving in..................................................................................................................................................222
16.2. Finding the path.......................................................................................................................................223
16.3. Filtering lists revisited..............................................................................................................................225
16.4. Mapping lists revisited.............................................................................................................................227
16.5. Data-centric programming.......................................................................................................................228
16.6. Dynamically importing modules..............................................................................................................229
16.7. Putting it all together................................................................................................................................230
16.8. Summary..................................................................................................................................................233
Chapter 17. Dynamic functions..................................................................................................................................234
17.1. Diving in..................................................................................................................................................234
17.2. plural.py, stage 1......................................................................................................................................234
17.3. plural.py, stage 2......................................................................................................................................236
17.4. plural.py, stage 3......................................................................................................................................238
17.5. plural.py, stage 4......................................................................................................................................239
17.6. plural.py, stage 5......................................................................................................................................241
17.7. plural.py, stage 6......................................................................................................................................242
17.8. Summary..................................................................................................................................................245
Chapter 18. Performance Tuning...............................................................................................................................246
18.1. Diving in..................................................................................................................................................246
18.2. Using the timeit Module..........................................................................................................................248
18.3. Optimizing Regular Expressions.............................................................................................................249
18.4. Optimizing Dictionary Lookups..............................................................................................................252
18.5. Optimizing List Operations......................................................................................................................255
18.6. Optimizing String Manipulation..............................................................................................................257
18.7. Summary..................................................................................................................................................259
Appendix A. Further reading.....................................................................................................................................260
Appendix B. A 5-minute review..................................................................................................................................267
Appendix C. Tips and tricks.......................................................................................................................................281
Appendix D. List of examples.....................................................................................................................................288
Appendix E. Revision history......................................................................................................................................301
Appendix F. About the book.......................................................................................................................................313
Appendix G. GNU Free Documentation License......................................................................................................314
G.0. Preamble....................................................................................................................................................314
G.1. Applicability and definitions.....................................................................................................................314
G.2. Verbatim copying......................................................................................................................................315
G.3. Copying in quantity...................................................................................................................................315
G.4. Modifications............................................................................................................................................316
G.5. Combining documents..............................................................................................................................317
G.6. Collections of documents..........................................................................................................................317
G.7. Aggregation with independent works.......................................................................................................317
Dive Into Python iv
Table of Contents
Appendix G. GNU Free Documentation License
G.8. Translation................................................................................................................................................317
G.9. Termination...............................................................................................................................................318
G.10. Future revisions of this license................................................................................................................318
G.11. How to use this License for your documents..........................................................................................318
Appendix H. Python license........................................................................................................................................319
H.A. History of the software.............................................................................................................................319
H.B. Terms and conditions for accessing or otherwise using Python..............................................................319
Dive Into Python v
剩余325页未读,继续阅读
cartoon_1
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0