Code formatting question: conditional expression
Ben Finney
ben+python at benfinney.id.au
Tue Aug 18 17:24:35 EDT 2009
"Diez B. Roggisch" <deets at nospam.web.de> writes:
> excessblk = None
> if total > P.BASE:
> excessblk = ...
>
> You don't lose any vertical space,
I don't see vertical space as such a scarce resource; we don't have an
imminent newline shortage, to my knowledge. I value it far lower than,
say, local readability.
> and it's much more readable IMHO.
On the basis of local readability, then, I agree that a multi-line
conditional expression is far less quickly comprehensible than a normal
multi-line ‘if’ statement. Assigning the default value of ‘None’ first
(if that's the default) is also good style IMO.
--
\ “Pinky, are you pondering what I'm pondering?” “Wuh, I think |
`\ so, Brain, but wouldn't anything lose its flavor on the bedpost |
_o__) overnight?” —_Pinky and The Brain_ |
Ben Finney
More information about the Python-list
mailing list