I'm experimenting with bytes vs bytearray in Python 2.6. I don't understand the reason for some differences.
A bytes iterator returns strings:
for i in bytes(b"hi"):
print(type(i))
Gives:
<type 'str'>
<type 'str'>
But a bytearray iterator returns ints:
for i in bytearray(b"hi"):
print(type(i))
Gives:
<type 'int'>
<type 'int'>
Why the difference?
I'd like to write code that will translate well into Python 3. So, is the situation the same in Python 3?