This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author flox
Recipients barry, docs@python, flox, ncoghlan
Date 2014-05-20.05:59:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400565584.02.0.148226279911.issue21540@psf.upfronthosting.co.za>
In-reply-to
Content
Python accepts both syntaxes:

    if not item in some_list and not item is None:
        return item

and

    if item not in some_list and item is not None:
        return item


In the first form, you identify 5 operators: "not", "in", "and", "not" and "in"
In the second form, you find only 3 operators: "not in", "and", "is not"


Of course CPython does internal optimization, and it compiles both expressions to the same bytecode.

However the second form is more readable and less error-prone. It is plain English.

I propose to add such advice to the section "Programming Recommendations" of PEP 8.
History
Date User Action Args
2014-05-20 05:59:44floxsetrecipients: + flox, barry, ncoghlan, docs@python
2014-05-20 05:59:44floxsetmessageid: <1400565584.02.0.148226279911.issue21540@psf.upfronthosting.co.za>
2014-05-20 05:59:43floxlinkissue21540 messages
2014-05-20 05:59:42floxcreate