comprehension parsing

philippe descharmes philippe.descharmes at sfr.fr
Sat Nov 5 21:55:00 EDT 2022


Hello, I‌ts probably a priority of avalauation in the chain of operators ans association of themselves. I'm not sure. Philippe.
 

De : "BlindAnagram"
A : python-list at python.org
Envoyé: dimanche 6 Novembre 2022 00:57
Objet : Re: comprehension parsing
 
On 05/11/2022 22:11, MRAB wrote: > On 2022-11-05 18:52, cactus wrote: >> On Saturday, 5 November 2022 at 16:06:52 UTC, cactus wrote: >> >> I should have quoted the full comprehensions: >> >>   all((srt(m, n) in c_np) == (srt(a, b) in c_ap)  for (m, a), (n, b) >> in combinations(na8, 2)) >>   all( srt(m, n) in c_np  ==  srt(a, b) in c_ap)  for (m, a), (n, b) >> in combinations(na8, 2)) > > The comparison operators can be chained, so: > >     a == b == c > > is equivalent to: > >     (a == b) and (b == c) > > except that the common term ('b' in this case) is evaluated only once. > > 'in' is one of those comparison operators, so: > >      srt(m, n) in c_np == srt(a, b) in c_ap > > is equivalent to: > >      (srt(m, n) in c_np) and (c_np == srt(a, b)) and (srt(a, b) in c_ap) > > except that the common terms ('c_np' and 'srt(a, b)') are evaluated only > once. > > Chaining makes most sense with multiple '==' or a series of '<' and/or > '<=' or a series of '>' and/or '>=', as in '1 <= n <= 10'. Thanks for a most helpful explanation -- https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list