a list/re problem

Grant Edwards invalid at invalid.invalid
Fri Dec 11 16:30:57 EST 2009


On 2009-12-11, Neil Cerutti <neilc at norwich.edu> wrote:
> On 2009-12-11, Grant Edwards <invalid at invalid.invalid> wrote:
>> [s[1:-1] for s in l if (s[0] == s[-1] == '*')]
>
> That last bit doesn't work right, does it, since an == expression
> evaluates to True or False, no the true or false value itself?

It works for me.  Doesn't it work for you?

>From the fine manual (section 5.9. Comparisons):

  Comparisons can be chained arbitrarily, e.g., x < y <= z is
  equivalent to x < y and y <= z, except that y is evaluated
  only once (but in both cases z is not evaluated at all when x
  < y is found to be false).

  


-- 
Grant Edwards                   grante             Yow! Hand me a pair of
                                  at               leather pants and a CASIO
                               visi.com            keyboard -- I'm living
                                                   for today!



More information about the Python-list mailing list