what is this kind of string: b'string' ?
Martin v. Loewis
martin at v.loewis.de
Sat Sep 4 13:35:24 EDT 2010
Am 04.09.2010 19:27, schrieb Stefan Behnel:
> Martin v. Loewis, 04.09.2010 18:52:
>> Am 01.09.2010 23:32, schrieb Stef Mientki:
>>> in winpdb I see strings like this:
>>>
>>> >>> a = b'string'
>>> >>> a
>>> 'string'
>>> >>> type(a)
>>> <type 'str'>
>>>
>>> what's the "b" doing in front of the string ?
>>
>> It's redundant.
>
> Not completely. (I know that you know this, but to those who don't, your
> answer may be misleading.)
Actually, I didn't think of this (knowing something and being aware of
it are different things ...)
I personally don't use it in the 2to3 way, because it requires Python
2.6. For code that needs to go back further, I typically do
b('string')
with a custom b() function. That's less efficient, of course, since it
causes a function call on evaluation.
Thanks,
Martin
More information about the Python-list
mailing list