effectivepython icon indicating copy to clipboard operation
effectivepython copied to clipboard

Item 3: mix-up between bytes and str?

Open mickbeaver opened this issue 5 years ago • 1 comments

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.

mickbeaver avatar Jun 26 '20 02:06 mickbeaver

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>

peterbayerle avatar Aug 08 '20 23:08 peterbayerle

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

bslatkin avatar Jun 01 '24 05:06 bslatkin