[issue32055] Reconsider comparison chaining for containment tests

Serhiy Storchaka report at bugs.python.org
Wed May 9 05:10:37 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

On other hand, beginners are confused even by chained "==". There are regular reports about this on the tracker and questions on Python-related resources.

I have found the chained "in" is useful in the following case

    len(string) >= 2 and string[0] == string[-1] in ("'", '"')

for testing if the string is quoted with a single or double quotes.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32055>
_______________________________________


More information about the Python-bugs-list mailing list