Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

b before some variables in winpdb

why is there numerous
b
before variables

I underline in red

User generated image
Avatar of aikimark
aikimark
Flag of United States of America image

Based on past experience with other dictionary objects, my guess is that it represents an internal binary storage format for these dictionary keys.  So, comparisons with these keys can only be done in a case-sensitive mode.

It might also be the result of a mix of string and float keys.
SOLUTION
Avatar of pepr
pepr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

So bytes are b?
But i do not see s for string?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

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
Avatar of pepr
pepr

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.