bslatkin / effectivepython

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

Item 3: mix-up between bytes and str? #88

Closed mickbeaver closed 4 months ago

mickbeaver commented 4 years ago

Hello,

I believe "bytes" and "str" may have been inadvertently swapped in this sentence. Am I reading that correctly?

When a handle is in text mode, it uses the system’s default text encoding to interpret binary data using the bytes.encode (for writing) and str.decode (for reading) methods.

peterbayerle commented 4 years ago

yes, just caught this too. For those interested it's at the top of page 10. a quick check in the interpreter shows bytes.encode doesn't exist:

>>> bytes.encode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'bytes' has no attribute 'encode'
>>> str.encode
<method 'encode' of 'str' objects>
bslatkin commented 4 months ago

Thanks for the report! This was a mix-up. Deduping with #93