I am looking through some unit testing code and I found this:
self.assertIn(b'Hello', res.body)
I know that this means bytes
in python 3 which returns a byte array, as i found here. I believe that the code was written for python 3.3 and am trying to figure out how it works in other versions (in my case 2.7) The related question that I found had a poorly written accepted answer with contradictory comments that confused me.
Questions:
- In what versions of python does
b'myString'
"work"? - How does it behave in python 2.x?
- How does it behave in python 3.x?
- Does that have something to do with the byte literal change?
bytes
does not return abytearray
in 3.x. Those are two separate but related types, similar tofrozenset
vs.set
ortuple
vs.list
. – abarnert Jul 17 '13 at 21:40