effectivepython
effectivepython copied to clipboard
Effective Python: Second Edition — Source Code and Errata for the Book
add item1
(2nd ed) ## What the book says > `dropwhile`, which is the opposite of `takewhile`, skips items from an iterator until the predicate function returns `True` for the first time:...
(2nd ed) ## Expected result Program should stop at `0`: ``` 3 ticks left 2 ticks left 1 ticks left 3 ticks left 2 ticks left 1 ticks left 0...
(2nd ed) The code block in the middle of the page is about `unittest.mock.patch` and yet, instead of calling `feed_animal(database, name, now)`, it calls `feed_func(database, name, now)` (a leftover of...
(2nd ed) See paragraph which starts with the words “`patch` works for many modules, ...”: There is a wrong cross-reference: > in the `setUp` and `tearDown` methods of `TestCase` classes...
The first line on page 10 in 2nd ed. instead of ... "using the bytes.encode (for writing) and str.decode (for reading)" I think it should be the other way round...
See ``` green_str = my_values.get('green', ['']) if green_str[0]: green = int(green_str[0]) else: green = 0 ```
I think there should only one game_logic here? ```python def game_logic(state, neighbors): # Do some blocking input/output in here: data = my_socket.recv(100) def game_logic(state, neighbors): if state == ALIVE: if...
I'm not sure if I understand the purpose correctly, but it seems that [the code below](https://github.com/bslatkin/effectivepython/blob/master/example_code/item_51.py#L101-L136) skips the `__setitem__` method when wrapping the decorator :hushed: It seems that the type...
2nd edition, Item 3: Know the Difference between `bytes` and `str`, in the last paragraph on page 9, it reads: > This fails because the file was opened in read...