You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix heading capitalization lecture-wide per qe-writing-006
Apply sentence case to all section headings (##, ###, ####) across the
entire lecture, not just the new Type Hints section. Only the first word
and proper nouns (e.g., Python) are capitalized.
Copy file name to clipboardExpand all lines: lectures/python_advanced_features.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ It's here
31
31
32
32
A variety of topics are treated in the lecture, including iterators, type hints, decorators and descriptors, and generators.
33
33
34
-
## Iterables and Iterators
34
+
## Iterables and iterators
35
35
36
36
```{index} single: Python; Iteration
37
37
```
@@ -130,7 +130,7 @@ next(nikkei_data)
130
130
next(nikkei_data)
131
131
```
132
132
133
-
### Iterators in For Loops
133
+
### Iterators in for loops
134
134
135
135
```{index} single: Python; Iterators
136
136
```
@@ -286,14 +286,14 @@ tags: [raises-exception]
286
286
max(y)
287
287
```
288
288
289
-
## `*` and `**`Operators
289
+
## `*` and `**`operators
290
290
291
291
`*` and `**` are convenient and widely used tools to unpack lists and tuples and to allow users to define functions that take arbitrarily many arguments as input.
292
292
293
293
In this section, we will explore how to use them and distinguish their use cases.
294
294
295
295
296
-
### Unpacking Arguments
296
+
### Unpacking arguments
297
297
298
298
When we operate on a list of parameters, we often need to extract the content of the list as individual arguments instead of a collection when passing them into functions.
299
299
@@ -400,7 +400,7 @@ To summarize, when `*list`/`*tuple` and `**dictionary` are passed into *function
400
400
401
401
The difference is that `*` will unpack lists and tuples into *positional arguments*, while `**` will unpack dictionaries into *keyword arguments*.
402
402
403
-
### Arbitrary Arguments
403
+
### Arbitrary arguments
404
404
405
405
When we *define* functions, it is sometimes desirable to allow users to put as many arguments as they want into a function.
406
406
@@ -558,7 +558,7 @@ Type hints connect to the {doc}`need for speed <need_for_speed>` discussion:
558
558
559
559
For now, the main benefit of type hints in day-to-day Python is **clarity and tooling support**, which becomes increasingly valuable as programs grow in size.
560
560
561
-
## Decorators and Descriptors
561
+
## Decorators and descriptors
562
562
563
563
```{index} single: Python; Decorators
564
564
```
@@ -584,7 +584,7 @@ It's very easy to say what decorators do.
584
584
585
585
On the other hand it takes a bit of effort to explain *why* you might use them.
586
586
587
-
#### An Example
587
+
#### An example
588
588
589
589
Suppose we are working on a program that looks something like this
590
590
@@ -675,7 +675,7 @@ Now the behavior of `f` is as we desire, and the same is true of `g`.
675
675
676
676
At the same time, the test logic is written only once.
677
677
678
-
#### Enter Decorators
678
+
#### Enter decorators
679
679
680
680
```{index} single: Python; Decorators
681
681
```
@@ -776,7 +776,7 @@ In the last two lines we see that `miles` and `kms` are out of sync.
776
776
777
777
What we really want is some mechanism whereby each time a user sets one of these variables, *the other is automatically updated*.
778
778
779
-
#### A Solution
779
+
#### A solution
780
780
781
781
In Python, this issue is solved using *descriptors*.
782
782
@@ -827,7 +827,7 @@ car.kms
827
827
828
828
Yep, that's what we want --- `car.kms` is automatically updated.
829
829
830
-
#### How it Works
830
+
#### How it works
831
831
832
832
The names `_miles` and `_kms` are arbitrary names we are using to store the values of the variables.
833
833
@@ -845,7 +845,7 @@ For example, after `car` is created as an instance of `Car`, the object `car.mil
845
845
Being a property, when we set its value via `car.miles = 6000` its setter
846
846
method is triggered --- in this case `set_miles`.
847
847
848
-
#### Decorators and Properties
848
+
#### Decorators and properties
849
849
850
850
```{index} single: Python; Decorators
851
851
```
@@ -898,7 +898,7 @@ A generator is a kind of iterator (i.e., it works with a `next` function).
898
898
899
899
We will study two ways to build generators: generator expressions and generator functions.
900
900
901
-
### Generator Expressions
901
+
### Generator expressions
902
902
903
903
The easiest way to build generators is using *generator expressions*.
904
904
@@ -954,7 +954,7 @@ In fact, we can omit the outer brackets in this case
0 commit comments