bslatkin / effectivepython

Effective Python: Second Edition — Source Code and Errata for the Book
https://effectivepython.com
2.2k stars 710 forks source link

Item #10: Incorrect assignment expression #95

Closed Leefir closed 1 month ago

Leefir commented 3 years ago

Page 39, Item 10, line 7 from bottom

to_enjoy‘= 'Nothing'

should be written as

to_enjoy = 'Nothing'

It is in the second code snippet on Page 39:

count = fresh_fruit.get('banana', 0)
if count >= 2:
    pieces = slice_bananas(count)
    to_enjoy = make_smoothies(pieces)
else:
    count = fresh_fruit.get('apple', 0)
    if count >= 4:
        to_enjoy = make_cider(count)
    else:
        count = fresh_fruit.get('lemon', 0)
        if count:
            to_enjoy = make_lemonage(count)
        else:
            to_enjoy‘= 'Nothing'
aambrioso1 commented 3 years ago

I also have this error in my hard copy of Effective Python (Second Edition). The code here: https://github.com/bslatkin/effectivepython/blob/master/example_code/item_10.py is correct. I have found the GitHub code to be well-done and instructive. Slatkin makes an effort to write the code so that it will run by building up any dummy functions, using exception handling where it would make the text version less readable, and occasionally adding more examples.

bslatkin commented 1 month ago

Thank you for the report! The extraneous ` was a typo.

bslatkin commented 1 month ago

Will be addressed in post-production