From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 6CB39393A422 for ; Tue, 8 Jun 2021 01:12:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6CB39393A422 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7DB0C340D6B; Tue, 8 Jun 2021 01:12:24 +0000 (UTC) Date: Mon, 7 Jun 2021 21:12:24 -0400 From: Mike Frysinger To: Lancelot SIX Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Use is/is not to check for None in python. Message-ID: Mail-Followup-To: Lancelot SIX , gdb-patches@sourceware.org References: <20210607225044.486370-1-lsix@lancelotsix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210607225044.486370-1-lsix@lancelotsix.com> X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jun 2021 01:12:35 -0000 On 07 Jun 2021 23:50, Lancelot SIX via Gdb-patches wrote: > While reviewing a patch sent to the mailing list, I noticed there are few > places where python code checks if a variable is 'None' or not by using the > comparison operators '==' and '!='. PEP8[1], which is used as coding standard > in GDB coding standards, recommends using 'is' / 'is not' when comparing to a > singleton such as 'None'. this is correct, so all the changes look fine. but i wonder if we couldn't make many more pythonic by treating them as bools. for example: > --- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py > +++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py > @@ -28,7 +28,7 @@ class Reverse_Function(FrameDecorator): > > def function(self): > fname = str(self.fobj.function()) > - if fname == None or fname == "": > + if fname is None or fname == "": this is simply: if not fname: -mike