Skip to content

Commit 79e91fd

Browse files
committed
Added links. Renumber
1 parent 45c7ec1 commit 79e91fd

9 files changed

Lines changed: 33 additions & 25 deletions

File tree

Notes/07_Advanced_Topics/01_Variable_arguments.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ These are not commonly used except when writing library functions.
8787

8888
## Exercises
8989

90-
### (a) A simple example of variable arguments
90+
### Exercise 7.1: A simple example of variable arguments
9191

9292
Try defining the following function:
9393

@@ -106,7 +106,7 @@ Try defining the following function:
106106

107107
Notice how the parameter `*more` collects all of the extra arguments.
108108

109-
### (b) Passing tuple and dicts as arguments
109+
### Exercise 7.2: Passing tuple and dicts as arguments
110110

111111
Suppose you read some data from a file and obtained a tuple such as
112112
this:
@@ -146,7 +146,7 @@ Stock('GOOG', 100, 490.1)
146146
>>>
147147
```
148148

149-
### (c) Creating a list of instances
149+
### Exercise 7.3: Creating a list of instances
150150

151151
In your `report.py` program, you created a list of instances
152152
using code like this:
@@ -169,7 +169,7 @@ def read_portfolio(filename):
169169

170170
You can simplify that code using `Stock(**d)` instead. Make that change.
171171

172-
### (d) Argument pass-through
172+
### Exercise 7.4: Argument pass-through
173173

174174
The `fileparse.parse_csv()` function has some options for changing the
175175
file delimiter and for error reporting. Maybe you'd like to expose those
@@ -211,4 +211,4 @@ Now, try silencing the errors:
211211
>>>
212212
```
213213

214-
[Next](02_Anonymous_function)
214+
[Contents](../Contents) \| [Previous (6.4 Generator Expressions)](../06_Generators/04_More_generators) \| [Next (7.2 Anonymous Functions)](02_Anonymous_function)

Notes/07_Advanced_Topics/02_Anonymous_function.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Stock('IBM', 100, 70.44)
108108
>>>
109109
```
110110

111-
### (a) Sorting on a field
111+
### Exercise 7.5: Sorting on a field
112112

113113
Try the following statements which sort the portfolio data
114114
alphabetically by stock name.
@@ -129,7 +129,7 @@ In this part, the `stock_name()` function extracts the name of a stock from
129129
a single entry in the `portfolio` list. `sort()` uses the result of
130130
this function to do the comparison.
131131

132-
### (b) Sorting on a field with lambda
132+
### Exercise 7.6: Sorting on a field with lambda
133133

134134
Try sorting the portfolio according the number of shares using a
135135
`lambda` expression:
@@ -158,4 +158,4 @@ Note: `lambda` is a useful shortcut because it allows you to
158158
define a special processing function directly in the call to `sort()` as
159159
opposed to having to define a separate function first (as in part a).
160160

161-
[Next](03_Returning_functions)
161+
[Contents](../Contents) \| [Previous (7.1 Variable Arguments)](01_Variable_arguments) \| [Next (7.3 Returning Functions)](03_Returning_function)

Notes/07_Advanced_Topics/03_Returning_functions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ You can write functions that make code.
119119

120120
## Exercises
121121

122-
### (a) Using Closures to Avoid Repetition
122+
### Exercise 7.7: Using Closures to Avoid Repetition
123123

124124
One of the more powerful features of closures is their use in
125125
generating repetitive code. If you refer back to exercise 5.2
@@ -195,7 +195,7 @@ Try creating an instance and verifying that type-checking works.
195195
>>>
196196
```
197197

198-
### (b) Simplifying Function Calls
198+
### Exercise 7.8: Simplifying Function Calls
199199

200200
In the above example, users might find calls such as
201201
`typedproperty('shares', int)` a bit verbose to type--especially if
@@ -226,9 +226,9 @@ Ah, that's a bit better. The main takeaway here is that closures and `lambda`
226226
can often be used to simplify code and eliminate annoying repetition. This
227227
is often good.
228228

229-
### (c) Putting it into practice
229+
### Exercise 7.9: Putting it into practice
230230

231231
Rewrite the `Stock` class in the file `stock.py` so that it uses typed properties
232232
as shown.
233233

234-
[Next](04_Function_decorators)
234+
[Contents](../Contents) \| [Previous (7.2 Anonymous Functions)](02_Anonymous_function) \| [Next (7.4 Decorators)](04_Function_decorators)

Notes/07_Advanced_Topics/04_Function_decorators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ However, the previous example is a good illustration of how their use tends to a
103103

104104
## Exercises
105105

106-
### (a) A decorator for timing
106+
### Exercise 7.10: A decorator for timing
107107

108108
If you define a function, its name and module are stored in the
109109
`__name__` and `__module__` attributes. For example:
@@ -149,4 +149,4 @@ Discussion: This `@timethis` decorator can be placed in front of any
149149
function definition. Thus, you might use it as a diagnostic tool for
150150
performance tuning.
151151

152-
[Next](05_Decorated_methods)
152+
[Contents](../Contents) \| [Previous (7.3 Returning Functions)](03_Returning_functions) \| [Next (7.5 Decorated Methods)](05_Decorated_methods)

Notes/07_Advanced_Topics/05_Decorated_methods.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Start this exercise by defining a `Date` class. For example:
121121
>>>
122122
```
123123

124-
### (a) Class Methods
124+
### Exercise 7.11: Class Methods
125125

126126
A common use of class methods is to provide alternate constructors
127127
(epecially since Python doesn't support overloaded methods). Modify
@@ -161,7 +161,7 @@ Yow!
161161
>>>
162162
```
163163

164-
### (b) Class Methods in Practice
164+
### Exercise 7.12: Class Methods in Practice
165165

166166
In your `report.py` and `portfolio.py` files, the creation of a `Portfolio`
167167
object is a bit muddled. For example, the `report.py` program has code like this:
@@ -258,3 +258,4 @@ To use this new Portfolio class, you can now write code like this:
258258
Make these changes to the `Portfolio` class and modify the `report.py`
259259
code to use the class method.
260260

261+
[Contents](../Contents) \| [Previous (7.4 Decorators)](04_Function_decorators) \| [Next (8 Testing and Debugging)](../08_Testing_debugging/00_Overview)

Notes/08_Testing_debugging/01_Testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ for Exercise 7.3. If, for some reason, that's not working,
207207
you might want to copy the solution from `Solutions/7_3` to your working
208208
directory.
209209

210-
### (a) Writing Unit Tests
210+
### Exercise 8.1: Writing Unit Tests
211211

212212
In a separate file `test_stock.py`, write a set a unit tests
213213
for the `Stock` class. To get you started, here is a small
@@ -261,4 +261,4 @@ class TestStock(unittest.TestCase):
261261
s.shares = '100'
262262
```
263263

264-
[Next](02_Logging)
264+
[Contents](../Contents) \| [Previous (7.5 Decorated Methods)](../07_Advanced_Topics/05_Decorated_methods) \| [Next (8.2 Logging)](02_Logging)

Notes/08_Testing_debugging/02_Logging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ However, the code that uses logging doesn't have to worry about that.
125125

126126
## Exercises
127127

128-
### (a) Adding logging to a module
128+
### Exercise 8.2: Adding logging to a module
129129

130130
In Exercise 3.3, you added some error handling to the
131131
`fileparse.parse_csv()` function. It looked like this:
@@ -282,7 +282,7 @@ Turn off all, but the most critical logging messages:
282282
>>>
283283
```
284284

285-
### (b) Adding Logging to a Program
285+
### Exercise 8.3: Adding Logging to a Program
286286

287287
To add logging to an application, you need to have some mechanism to
288288
initialize the logging module in the main module. One way to
@@ -302,4 +302,4 @@ logging.basicConfig(
302302
Again, you'd need to put this someplace in the startup steps of your
303303
program.
304304

305-
[Next](03_Debugging)
305+
[Contents](../Contents) \| [Previous (8.1 Testing)](01_Testing) \| [Next (8.3 Debugging)](03_Debugging)

Notes/08_Testing_debugging/03_Debugging.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,10 @@ For breakpoints location is one of the following.
145145
(Pdb) b module.foo # Function foo() in a module
146146
```
147147

148+
## Exercises
149+
150+
### Exercise 8.4: Bugs? What Bugs?
151+
152+
It runs. Ship it!
153+
154+
[Contents](../Contents) \| [Previous (8.2 Logging)](02_Logging) \| [Next (9 Packages)](../09_Packages/00_Overview)

Notes/09_Packages/01_Packages.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ typedproperty.py # Typed class properties
245245
In this exercise, we're going to clean up the code and put it into
246246
a common package.
247247

248-
### (a) Making a simple package
248+
### Exercise 9.1: Making a simple package
249249

250250
Make a directory called `porty/` and put all of the above Python
251251
files into it. Additionally create an empty `__init__.py` file and
@@ -298,7 +298,7 @@ from .fileparse import parse_csv
298298
...
299299
```
300300

301-
### (b) Making an application directory
301+
### Exercise 9.2: Making an application directory
302302

303303
Putting all of your code into a "package" isn't often enough for an
304304
application. Sometimes there are supporting files, documentation,
@@ -358,7 +358,7 @@ shell % python3 -m porty.report portfolio.csv prices.csv txt
358358
shell %
359359
```
360360

361-
### (c) Top-level Scripts
361+
### Exercise 9.3: Top-level Scripts
362362

363363
Using the `python -m` command is often a bit weird. You may want to
364364
write a top level script that simply deals with the oddities of packages.
@@ -412,4 +412,4 @@ porty-app/
412412
typedproperty.py
413413
```
414414

415-
[Next](02_Third_party)
415+
[Contents](../Contents) \| [Previous (8.3 Debugging)](../08_Testing_debugging/03_Debugging) \| [Next (9.2 Third Party Packages)](02_Third_party)

0 commit comments

Comments
 (0)