[nvda-addons] Re: Tone Master addon now on github

  • From: James Scholes <james@xxxxxxxxxxxxx>
  • To: nvda-addons@xxxxxxxxxxxxx
  • Date: Mon, 18 Jul 2016 10:47:52 +0100

Joseph Lee wrote:

* Loaded == None versus Lloaded is None versus not loaded: it's up to you. 
Usually "loaded is None" might be a bit more clear.

The semantic meaning of all three snipets of code is completely different.

1. If you're checking whether an object is None, you should use is.
None is a singleton, and equality comparisons with singleton objects are
discouraged.  You wouldn't write, for example:
if x > None
So it doesn't make much sense to use == either.  Also using is is
slightly faster when checking for None objects.
2. Using not should probably be limited to boolean logic only.  If you
have a value that can be None, your code should make that clear.  If
your value will always be initialised to either True or False, using:
if loaded
and
if not loaded:
is fine.
-- 
James Scholes
http://twitter.com/JamesScholes
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting 
bugs. 

Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe: 
//www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

Other related posts: