
On Aug 26, 2013 3:24 AM, "Chris Angelico" <rosuav@gmail.com> wrote:
On Mon, Aug 26, 2013 at 2:50 PM, Clay Sweetser <clay.sweetser@gmail.com>
wrote:
Meaning either that one must write either this, and use parenthesis to avoid some obscure order of operations error: def is_enabled(self): return ( (self.connected) and (not self.broadcasting) and (self.mode is 'client') )
I'd be inclined toward this option, especially if some of your expressions are complex checks - the 'and' will short-circuit, a tuple won't. It looks perfectly readable, to me. Side point: I'd be cautious about using 'is' with strings, unless you have some way of guaranteeing that both sides have been interned. Heh, I had actually changed that snippet somewhat from its original source. My own code uses many constants, so it's something like "MODE is CLIENT_TO_CLIENT" (The way commands in sublime text are written makes it almost mandatory to use globals in order to share state).
ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas