From: Mike Frysinger <vapier@gentoo.org>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Use is/is not to check for None in python.
Date: Mon, 7 Jun 2021 21:12:24 -0400 [thread overview]
Message-ID: <YL7D+CMN7Jf+UmFQ@vapier> (raw)
In-Reply-To: <20210607225044.486370-1-lsix@lancelotsix.com>
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
next prev parent reply other threads:[~2021-06-08 1:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-07 22:50 Lancelot SIX
2021-06-08 1:12 ` Mike Frysinger [this message]
2021-06-08 16:25 ` Simon Marchi
2021-06-08 23:01 ` Lancelot SIX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YL7D+CMN7Jf+UmFQ@vapier \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).