List question

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Mar 21 18:56:34 EDT 2008


Ricky Zhou:
> Look at the this line:
>     if 'one' and 'two' in f:

Very cute, it's the first time I see a bug like this. I think it's not
a common enough pattern to justify a language change, but a bit
smarter computer language may be able to do that too ;-) (it's not
easy to tell the two meanings apart, from a simple point of view the
semantics is ambiguous) Maybe an AppleScript-like language can be
designed to have such capabilities too :-)

A more computer-friendly (and Pythonic) syntax may be ('are' is a
keyword):
if ('one', 'two') are in f: ...
That's sugar for:
if all(x in f for x in ('one', 'two')): ...

Bye,
bearophile



More information about the Python-list mailing list