a list/re problem

Neil Cerutti neilc at norwich.edu
Mon Dec 14 08:38:29 EST 2009


On 2009-12-11, Grant Edwards <invalid at invalid.invalid> wrote:
> 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).

I did not know that. Thanks, Grant.

-- 
Neil Cerutti



More information about the Python-list mailing list