Hacker News new | ask | show | jobs
by arundelo 3437 days ago
(pro tip: a b'foo' object in Python2.7 or Python3 isn't "a bytes", it's "a bytestring".)

Quotes from the Python 3 documentation:

Bytes literals are always prefixed with 'b' or 'B'; they produce an instance of the bytes type instead of the str type.

class bytes([source[, encoding[, errors]]])

Return a new “bytes” object, which is an immutable sequence of integers in the range 0 <= x < 256. bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavior.

https://docs.python.org/3/library/functions.html#bytes

https://docs.python.org/3/reference/lexical_analysis.html#st...

1 comments

"bytes" is the type for bytestrings on both Python 2 and 3.