[Python-ideas] bytes indexing behavior

Michael Selik michael.selik at gmail.com
Fri Jul 8 12:26:08 EDT 2016


On Fri, Jul 8, 2016, 1:03 AM Franklin? Lee <leewangzhong+python at gmail.com>
wrote:

> On Jul 6, 2016 2:40 PM, "Michael Selik" <michael.selik at gmail.com> wrote:
> > Instead it seems the best way given the current behavior is to write:
> >
> >     len(bytestring) == bytestring.count(b'z')
> >
> > While I wait for PEP 467, can anyone suggest a better way to write that?
>
> How about
>     set(bytestring) == set(b'z')
>
Ah, that makes sense. I'd thought of using a set literal on the right-hand,
but for some reason using set constructor slipped my mind.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160708/33ad4dae/attachment-0001.html>


More information about the Python-ideas mailing list