A curious bit of code...

Terry Reedy tjreedy at udel.edu
Fri Feb 14 01:29:33 CET 2014


On 2/13/2014 1:37 PM, forman.simon at gmail.com wrote:
> I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure.
>
>    if key[:1] + key[-1:] == '<>': ...

if key[:1] == '<' and key[-1:] == '>: ...
is the obvious choice to me. If the first clause is false, it never 
computes the second.

-- 
Terry Jan Reedy




More information about the Python-list mailing list