First python program, syntax error in while loop

Chris Angelico rosuav at gmail.com
Mon May 6 17:50:59 EDT 2013


On Tue, May 7, 2013 at 6:11 AM, Terry Jan Reedy <tjreedy at udel.edu> wrote:
> On 5/6/2013 11:31 AM, Roy Smith wrote:
>>
>> In article <mailman.1361.1367847484.3114.python-list at python.org>,
>> Chris Angelico  <rosuav at gmail.com> wrote:
>>> If I ever have even the slightest doubt, I just go ahead and type
>>> "<language> operator precedence" into a web search and check it :)
>>
>>
>> Well, that solves the problem once, and it solves it for me.  I figure
>> if I'm not 100% sure, then maybe other people aren't 100% sure either,
>> and my adding the extra parens helps them too.
>
>
> If you keep the Python docs handy, on or off line, the Language manual
> Expressions chapter ends with this single page (but better formatted as a
> table than here). But I sometimes add parens for quickness or readability.
>
> or Boolean OR
> and Boolean AND

Actually, this is one exception. I tend to parenthesize any case where
there's a complex set of conditions and mixed AND and OR operations.
Part of the reason for this is that any expression that can be
affected by the precedence of and and or will most likely be fairly
long and/or complex anyway, so a few extra parens won't hurt.

ChrisA



More information about the Python-list mailing list