rgb192
asked on
b before some variables in winpdb
Yep. These are byte data types
https://docs.python.org/3.1/library/stdtypes.html#bytes-and-byte-array-methods
https://docs.python.org/3.1/library/stdtypes.html#bytes-and-byte-array-methods
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So bytes are b?
But i do not see s for string?
But i do not see s for string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are seeing the ASCII characters within the string. I would expect to see non-printable characters once the byte values exceed 127
So now I know why I only see 'b'
Thanks
What you see is the representation of the object. There is the built-in function repr() that returns the representation. The representation is a string that--when copy/pasted into a source code--would produce the object with the same value. (This is ideal case, it is not possible for more complex objects. But this is the idea.)
In Python 3, strings literals are written as 'some string', or in single or in double quotes. There is nothing like an s prefix. Because of that, the representation is 'some string'. The bytes type was not present in Python 2. In Python 3, b'some characters' is the way how to type-in the sequence of characters that will not be interpreted as Unicode string. If the source code is written (using editor) in some 8-bit encoding, when looping through the bytes sequence, you get integers for each byte.
In Python 3, strings literals are written as 'some string', or in single or in double quotes. There is nothing like an s prefix. Because of that, the representation is 'some string'. The bytes type was not present in Python 2. In Python 3, b'some characters' is the way how to type-in the sequence of characters that will not be interpreted as Unicode string. If the source code is written (using editor) in some 8-bit encoding, when looping through the bytes sequence, you get integers for each byte.
It might also be the result of a mix of string and float keys.