surprise - byte in set

Amir Arsalan am1r.ar3alan at gmail.com
Sat Jan 3 20:08:42 CET 2015


Hi my friends.

On last result you have  a , b , c  binary.

>> set('abc')
{'a','b','c')
>> set(b'abc')
{97,98,99}
On Jan 3, 2015 10:25 PM, "patrick vrijlandt" <pvrijlandt at gmail.com> wrote:

> Hello list,
>
> Let me first wish you all the best in 2015!
>
> Today I was trying to test for occurrence of a byte in a set ...
>
> >>> 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)
>
> Patrick
>
> ---
> Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
> http://www.avast.com
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150103/7acd0fbb/attachment.html>


More information about the Python-list mailing list