[Tutor] a logic problem in an if statement

Bill Allen wallenpb at gmail.com
Mon Sep 27 02:17:22 CEST 2010


On Sun, Sep 26, 2010 at 5:12 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> On Mon, 27 Sep 2010 06:01:35 am Bill Allen wrote:
>
> Now your decision logic becomes simple, and obvious. It documents
> itself:
>
> if click_in_bottom_half1 and click_in_bottom_half2:
>    print "Both clicks in bottom half of screen"
> elif click_in_bottom_half1:
>    print "The first click was in the bottom half."
>    print "The second click was in the top half."
> elif click_in_bottom_half2:
>    print "The first click was in the top half."
>    print "The second click was in the bottom half."
> else:
>    print "Both clicks in top half of screen"
>
>
>
> --
> Steven D'Aprano
>

Steven,

Those are great suggestions and certainly do simplify matters quite a bit.
I had not realized the I was including such redundancies into my code.  I
have some other code I need to now go back through and see what
simplifications I can there also make.

Thanks!

--Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100926/c02f85e5/attachment.html>


More information about the Tutor mailing list