if, continuation and indentation

Xavier Ho contact at xavierho.com
Thu May 27 08:48:01 EDT 2010


On 27 May 2010 22:22, HH <henrikho at gmail.com> wrote:

>    if (width == 0 and
>        height == 0 and
>        color == 'red' and
>        emphasis == 'strong' or
>        highlight > 100):
>        raise ValueError("sorry, you lose")
>

I've gotta say - I've bumped into this problem before, and I'm sure many
other have - this is a valid question. It just hasn't bothered me enough to
ask...

Correct me if I'm wrong, but I think the following is equivalent, and looks
better. Although this won't fix all ugly cases in that problem.

if (width, height, color, emphasis) == (0, 0, 'red', 'strong') or highlight
> 100:
    raise ValueError("sorry, you lose")

Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100527/aa389897/attachment-0001.html>


More information about the Python-list mailing list