surprise - byte in set

Jason Friedman jsf80238 at gmail.com
Sat Jan 3 20:12:46 CET 2015


>>>> sys.version
> '3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit
> (Intel)]'
>>>> 'b' in 'abc'
> True
>>>> b'b' in b'abc'
> True
>>>> 'b' in set('abc')
> True
>>>> b'b' in set(b'abc')
> False
>
> I was surprised by the last result. What happened?
> (Examples simplified; I was planning to manipulate the set)

I'm no expert, but I see:

>>> for i in set(b'abc'):
...     print(type(i))
...
<class 'int'>
<class 'int'>
<class 'int'>



More information about the Python-list mailing list