bslatkin / effectivepython

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

Item 21 - class definition #63

Closed jonfernandes closed 4 months ago

jonfernandes commented 4 years ago

The return statement is not within the method definition. i.e. it should be this

class Sorter:
...
def __call__(self, x):
        if x in self.group:
            self.found = True
            return (0, x)
        return (1, x)

NOT

class Sorter:
...
def __call__(self, x):
        if x in self.group:
            self.found = True
            return (0, x)
return (1, x)
bslatkin commented 4 years ago

@jonfernandes Thanks for the report. I don't see it this way in my copy of the book. Can you provide more context about where you saw it this way? Was it an ebook version or kindle or something like that? Thanks

cihati commented 4 years ago

@bslatkin I came here to report the same bug as well. Seems like @jonfernandes forgot to follow up on your question. Here's where I see it:

image

from https://learning.oreilly.com/library/view/effective-python-90/9780134854717/ch03.xhtml

bslatkin commented 4 years ago

Gotcha. This appears to be an issue with the O'Reilly eBook specifically. I'll have to follow up with the publisher to figure this out. Thanks for the extra info @cihati!

bslatkin commented 4 months ago

Going to follow up on this one for post-production