List question

John Machin sjmachin at lexicon.net
Sun Mar 23 18:55:43 EDT 2008


On Mar 24, 12:19 am, Dustan <DustanGro... at gmail.com> wrote:
> On Mar 21, 3:57 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
>
> > From at home writes:
> > >    if 'one' and 'two' in f:
> > >            alist.append(f)
>
> > Use:
> >      if 'one' in f and 'two'  in f: ...
>
> Personally, I would put parentheses around to be clearer:
>
> if ('one' in f) and ('two'  in f): ...
>
> I'm not saying to put parentheses around everything, but in the more
> ambiguous cases, it certainly helps.

Please help me understand why this is a "more ambiguous" case.

To me,  alternative interpretations have extremely low scores for
utility and likelihood:

(1) 'and' has higher precedence than 'in':

    'one' in (f and 'two') in f # chained (x in y in z)

(2) 'and' has same precedence as 'in':

    (('one' in f) and 'two') in f

Cheers,
John



More information about the Python-list mailing list