@@ -8,29 +8,30 @@ kernelspec:
88 language : python
99 name : python3
1010heading-map :
11+ More Language Features : 更多语言特性
1112 Overview : 概述
12- Iterables and Iterators : 可迭代对象与迭代器
13- Iterables and Iterators ::Iterators : 迭代器
14- Iterables and Iterators ::Iterators in For Loops : For 循环中的迭代器
15- Iterables and Iterators ::Iterables : 可迭代对象
16- Iterables and Iterators ::Iterators and built-ins : 迭代器与内置函数
17- ' `*` and `**` Operators ' : ' `*` 和 `**` 运算符'
18- ' `*` and `**` Operators ::Unpacking Arguments ' : 解包参数
19- ' `*` and `**` Operators ::Arbitrary Arguments ' : 任意数量的参数
20- Decorators and Descriptors : 装饰器与描述符
21- Decorators and Descriptors ::Decorators : 装饰器
22- Decorators and Descriptors ::Decorators::An Example : 一个示例
23- Decorators and Descriptors ::Decorators::Enter Decorators : 引入装饰器
24- Decorators and Descriptors ::Descriptors : 描述符
25- Decorators and Descriptors ::Descriptors::A Solution : 解决方案
26- Decorators and Descriptors ::Descriptors::How it Works : 工作原理
27- Decorators and Descriptors ::Descriptors::Decorators and Properties : 装饰器与属性
13+ Iterables and iterators : 可迭代对象与迭代器
14+ Iterables and iterators ::Iterators : 迭代器
15+ Iterables and iterators ::Iterators in for loops : For 循环中的迭代器
16+ Iterables and iterators ::Iterables : 可迭代对象
17+ Iterables and iterators ::Iterators and built-ins : 迭代器与内置函数
18+ ' `*` and `**` operators ' : ' `*` 和 `**` 运算符'
19+ ' `*` and `**` operators ::Unpacking arguments ' : 解包参数
20+ ' `*` and `**` operators ::Arbitrary arguments ' : 任意数量的参数
21+ Decorators and descriptors : 装饰器与描述符
22+ Decorators and descriptors ::Decorators : 装饰器
23+ Decorators and descriptors ::Decorators::An example : 一个示例
24+ Decorators and descriptors ::Decorators::Enter decorators : 引入装饰器
25+ Decorators and descriptors ::Descriptors : 描述符
26+ Decorators and descriptors ::Descriptors::A solution : 解决方案
27+ Decorators and descriptors ::Descriptors::How it works : 工作原理
28+ Decorators and descriptors ::Descriptors::Decorators and properties : 装饰器与属性
2829 Generators : 生成器
29- Generators::Generator Expressions : 生成器表达式
30- Generators::Generator Functions : 生成器函数
31- Generators::Generator Functions ::Example 1 : 示例 1
32- Generators::Generator Functions ::Example 2 : 示例 2
33- Generators::Advantages of Iterators : 迭代器的优势
30+ Generators::Generator expressions : 生成器表达式
31+ Generators::Generator functions : 生成器函数
32+ Generators::Generator functions ::Example 1 : 示例 1
33+ Generators::Generator functions ::Example 2 : 示例 2
34+ Generators::Advantages of iterators : 迭代器的优势
3435 Exercises : 练习
3536---
3637
@@ -66,6 +67,7 @@ heading-map:
6667现在让我们更仔细地了解它的工作原理,重点关注 Python 中 ` for ` 循环的实现。
6768
6869(iterators)=
70+
6971### 迭代器
7072
7173``` {index} single: Python; Iterators
@@ -655,6 +657,7 @@ def g(x):
655657在许多人看来,这使得装饰器语法成为对语言的重大改进。
656658
657659(descriptors)=
660+
658661### 描述符
659662
660663``` {index} single: Python; Descriptors
@@ -809,6 +812,7 @@ class Car:
809812如需进一步了解,可以参考[ 描述符文档] ( https://docs.python.org/3/howto/descriptor.html ) 。
810813
811814(paf_generators)=
815+
812816## 生成器
813817
814818``` {index} single: Python; Generators
@@ -1079,15 +1083,14 @@ sum(draws)
10791083* 避免了创建大型列表/元组的需要,以及
10801084* 提供了一个统一的迭代接口,可以在 ` for ` 循环中透明地使用。
10811085
1082-
10831086## 练习
10841087
10851088
10861089``` {exercise-start}
10871090:label: paf_ex1
10881091```
10891092
1090- 完成以下代码,并使用[ 此 csv 文件] ( https://raw.githubusercontent.com/QuantEcon/lecture-python-programming/master/source /_static/lecture_specific/python_advanced_features/test_table.csv ) 进行测试,我们假设你已将该文件放在当前工作目录中:
1093+ 完成以下代码,并使用[ 此 csv 文件] ( https://raw.githubusercontent.com/QuantEcon/lecture-python-programming/main/lectures /_static/lecture_specific/python_advanced_features/test_table.csv ) 进行测试,我们假设你已将该文件放在当前工作目录中:
10911094
10921095``` {code-block} python3
10931096:class: no-execute
@@ -1140,4 +1143,4 @@ for date in dates:
11401143```
11411144
11421145``` {solution-end}
1143- ```
1146+ ```
0 commit comments