Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 402d197

Browse files
authored
Merge pull request dabeaz-course#98 from wo-von/practical-python-edits
Practical python edits
2 parents 2876ab8 + adb5c99 commit 402d197

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

Notes/05_Object_model/02_Classes_encapsulation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ One approach: introduce accessor methods.
9595
class Stock:
9696
def __init__(self, name, shares, price):
9797
self.name = name
98-
self.set_shares(shares)
99-
self.price = price
98+
self.set_shares(shares)
99+
self.price = price
100100

101101
# Function that layers the "get" operation
102102
def get_shares(self):

Notes/06_Generators/01_Iteration_protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ _iter = obj.__iter__() # Get iterator object
4242
while True:
4343
try:
4444
x = _iter.__next__() # Get next item
45+
# statements ...
4546
except StopIteration: # No more items
4647
break
47-
# statements ...
4848
```
4949

5050
All the objects that work with the `for-loop` implement this low-level

Notes/06_Generators/03_Producers_consumers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ opening a file--it merely operates on a sequence of lines given
124124
to it as an argument. Now, try this:
125125

126126
```
127+
>>> from follow import follow
127128
>>> lines = follow('Data/stocklog.csv')
128129
>>> ibm = filematch(lines, 'IBM')
129130
>>> for line in ibm:

Notes/07_Advanced_Topics/03_Returning_functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Consider a function like this:
8686

8787
```python
8888
def after(seconds, func):
89+
import time
8990
time.sleep(seconds)
9091
func()
9192
```
@@ -110,6 +111,7 @@ def add(x, y):
110111
return do_add
111112

112113
def after(seconds, func):
114+
import time
113115
time.sleep(seconds)
114116
func()
115117

0 commit comments

Comments
 (0)