A certainl part of an if() structure never gets executed.
Kushal Kumaran
kushal.kumaran+python at gmail.com
Thu Jun 13 00:35:50 EDT 2013
Chris Angelico <rosuav at gmail.com> writes:
> On Thu, Jun 13, 2013 at 11:55 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> In English:
>>
>> "the cat is in the box or the cupboard or the kitchen"
>>
>> means:
>>
>> "the cat is in the box, or the cat is in the cupboard, or the cat is in
>> the kitchen".
>>
>>
>> But that is not how Python works. In Python, you have to say:
>>
>> cat in box or cat in cupboard or cat in kitchen
>
> Or you can deem that there be one single location that is the merging
> of box, cupboard, and kitchen, and say:
>
> cat in (box+cupboard+kitchen)
>
> which works fine for character-in-string and element-in-list searches.
>
hm...
In [1]: s1 = 'abc'
In [2]: s2 = 'def'
In [3]: s3 = 'ghi'
In [4]: 'cd' in s1 or 'cd' in s2 or 'cd' in s3
Out[4]: False
In [5]: 'cd' in s1+s2+s3
Out[5]: True
--
regards,
kushal
More information about the Python-list
mailing list