effectivepython icon indicating copy to clipboard operation
effectivepython copied to clipboard

bytes.encode/str.decode -> str.encode/bytes.decode?

Open hoxell opened this issue 4 years ago • 0 comments

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 using bytes.encode (for writing) and str.decode (for reading) methods.

I think it's supposed be:

[...] str.encode (for writing) and bytes.decode (for reading) methods.

hoxell avatar Nov 07 '21 14:11 hoxell