"if {negative}" vs. "if {positive}" style (was: New to Python)
Simon Brunning
simon at brunningonline.net
Wed Feb 10 06:12:26 EST 2010
On 10 February 2010 03:36, Tim Chase <python.list at tim.thechases.com> wrote:
> Any thoughts on how others make the choice?
There are two criteria that I use here. I'll often tend towards the
positive test; it's just that little bit easier to comprehend, I
think. On the other hand, if one case is overwhelmingly more common,
I'll usually put that first even if it does mean using a negative
test.
I'm not buying the short-case-first argument. If the code in a case
block is long enough for that to matter, it really belongs in a
function of its own anyway.
--
Cheers,
Simon B.
More information about the Python-list
mailing list