没有合适的资源?快使用搜索试试~ 我知道了~
首页Intermediate Python
Intermediate Python
5星 · 超过95%的资源 需积分: 9 44 下载量 86 浏览量
更新于2023-06-03
2
收藏 1.01MB PDF 举报
This is a new python book that introduces some intermediate tech such as advanced function, decorators, generators etc.
资源详情
资源推荐
Contents
I Preface 1
II Author 2
1 *args and **kwargs 3
1.1 Usage of *args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Usage of **kwargs . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Using *args and **kwargs to call a function . . . . . . . . . . . . . 4
1.4 When to use them? . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Debugging 6
3 Generators 8
3.1 Iterable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Map & Filter 12
4.1 1. Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 2. Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5 set Data Structure 14
i
6 Ternary Operators 16
7 Decorators 18
7.1 Everything in python is an object: . . . . . . . . . . . . . . . . . . 18
7.2 Defining functions within functions: . . . . . . . . . . . . . . . . . 19
7.3 Returning functions from within functions: . . . . . . . . . . . . . 20
7.4 Giving a function as an argument to another function: . . . . . . 21
7.5 Writing your first decorator: . . . . . . . . . . . . . . . . . . . . . 21
7.6 1. Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.7 2. Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8 Global & Return 26
9 Mutation 28
10 __slots__ Magic 31
11 Virtual Environment 33
12 Collections 35
12.1 1.defaultdict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
12.2 2.counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
12.3 3.deque . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
12.4 4.namedtuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13 Enumerate 41
14 Object introspection 43
14.1 1.dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
14.2 2.type and id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
14.3 3.inspect module . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
15 Comprehensions 45
15.1 list comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . 45
15.2 dict comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . 46
15.3 set comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . 47
16 Exceptions 48
16.1 Handling multiple exceptions: . . . . . . . . . . . . . . . . . . . . 48
17 Lambdas 51
18 One Liners 53
ii
19 For - Else 55
19.1 1.else clause: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
20 Open function 57
21 Targeting Python 2+3 60
22 Coroutines 63
23 Function caching 65
23.1 Python 3.2+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
23.2 Python 2+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
24 Context managers 67
24.1 Implementing Context Manager as a Class: . . . . . . . . . . . . . 68
24.2 Handling exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . 69
24.3 Implementing a Context Manager as a Generator . . . . . . . . . 70
iii
iv
剩余75页未读,继续阅读
fatespinner123
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 保险服务门店新年工作计划PPT.pptx
- 车辆安全工作计划PPT.pptx
- ipqc工作总结PPT.pptx
- 车间员工上半年工作总结PPT.pptx
- 保险公司员工的工作总结PPT.pptx
- 报价工作总结PPT.pptx
- 冲压车间实习工作总结PPT.pptx
- ktv周工作总结PPT.pptx
- 保育院总务工作计划PPT.pptx
- xx年度现代教育技术工作总结PPT.pptx
- 出纳的年终总结PPT.pptx
- 贝贝班班级工作计划PPT.pptx
- 变电值班员技术个人工作总结PPT.pptx
- 大学生读书活动策划书PPT.pptx
- 财务出纳月工作总结PPT.pptx
- 大学生“三支一扶”服务期满工作总结(2)PPT.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功