while loop - multiple condition
Rob Gaddi
rgaddi at technologyhighland.invalid
Mon Oct 13 12:12:48 EDT 2014
On Mon, 13 Oct 2014 09:56:02 +1100
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>
> When you have multiple clauses in the condition, it's easier to reason about
> them if you write the clauses as positive statements rather than negative
> statements, that is, "something is true" rather than "something is not
> true", and then use `not` to reverse it if you want to loop *until* the
> overall condition is true.
>
I was just explaining this concept to a young pup the other day. De
Morgan's lets you say that (not (p and q)) == ((not p) or (not q)), but
the positive logic flavor is substantially less error-prone. People
are fundamentally not as good at thinking about inverted logic.
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
More information about the Python-list
mailing list