"if {negative}" vs. "if {positive}" style (was: New to Python)
Daniel Stutzbach
daniel at stutzbachenterprises.com
Tue Feb 9 22:58:02 EST 2010
On Tue, Feb 9, 2010 at 9:36 PM, Tim Chase <python.list at tim.thechases.com>wrote:
> removing the "not" from the condition. I admit I choose one over the other
> based on some gut-feeling aesthetic that I can't really nail down. I think
> one of my major influencing factors revolves around the negative "not"
> portion having one or two lines and the positive portion having a large
> block of code.
If one block is much shorter, I tend to put the shorter block first. That
way, the "else" and the "if" are almost always on the screen together at the
same time. If they're both long, I factor out one or both of the blocks
into functions.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100209/75670dee/attachment-0001.html>
More information about the Python-list
mailing list