if, continuation and indentation

Xavier Ho contact at xavierho.com
Thu May 27 09:26:54 EDT 2010


On 27 May 2010 22:57, Jean-Michel Pichavant <jeanmichel at sequans.com> wrote:

>  One possible solution
>>
>>   if (
>>           width == 0 and
>>           height == 0 and
>>           color == 'red' and
>>           emphasis == 'strong' or
>>           highlight > 100
>>      ):
>>       raise ValueError("sorry, you lose")
>>
>
Oh, one minor optimisation. You can put the last condition first:

  if (
          highlight > 100 or
          width == 0 and
          height == 0 and
          color == 'red' and
          emphasis == 'strong'
     ):
      raise ValueError("sorry, you lose")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100527/e77ced48/attachment-0001.html>


More information about the Python-list mailing list