effectivepython
effectivepython copied to clipboard
bytes.encode/str.decode -> str.encode/bytes.decode?
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 text mode (
'r') instead of read binary mode ('rb'). When a handle is in text mode, it uses the system's default text encoding to interpret binary data usingbytes.encode(for writing) andstr.decode(for reading) methods.
I think it's supposed be:
[...]
str.encode(for writing) andbytes.decode(for reading) methods.