effectivepython
effectivepython copied to clipboard
Item 3: mix-up between bytes and str?
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) andstr.decode(for reading) methods.
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>
Thanks for the report! This was a mix-up. Deduping with #93