From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oIgGHyzEvmANUAAAWB0awg (envelope-from ) for ; Mon, 07 Jun 2021 21:13:16 -0400 Received: by simark.ca (Postfix, from userid 112) id 6E8031F163; Mon, 7 Jun 2021 21:13:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5B96A1E54D for ; Mon, 7 Jun 2021 21:13:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99F56393A42F for ; Tue, 8 Jun 2021 01:13:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99F56393A42F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623114793; bh=4gp9WdS+xRq0WpinBrTov/b87SsJ8RTX43BMxqbDykk=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=a3MMmUPLcAsPLC55fOTqAHjGmNzhnZFujr1clJZM5XgHfasDOPz1cIqPUynTsKoTM SwaDc/toRl3eDFnX1Wlmi5wxLZwwpeX5e1yY+u6CwstYOf4auvL1w8q+8Z+4rF4Zrm RrXzNYM+BDosO3wmZcG6gOwBVyXfRbyrG9N5wDyA= 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 To: Lancelot SIX 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-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: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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