Odd truth result with in and ==

DL Neil PythonList at DancesWithMice.info
Wed Nov 21 17:04:30 EST 2018


Serhiy,

On 22/11/18 10:50, Serhiy Storchaka wrote:
> 21.11.18 22:17, Cameron Simpson пише:
>> Can someone show me a real world, or failing that - sane looking, 
>> chained comparison using "in"?
> 
>      s[0] == s[-1] in '\'"'
> 
> Tests that string s starts and ends with a single or double quote.


Am admiring this solution. Don't most people resort immediately to 
regular expressions?

Did you just 'come up with' this idea, or have you performed any testing 
to say that this is the most efficient/not too much more expensive...?

-- 
Please advise =dn



More information about the Python-list mailing list