A certainl part of an if() structure never gets executed.

Νικόλαος Κούρας support at superhost.gr
Thu Jun 13 10:47:28 EDT 2013


On 13/6/2013 12:16 πμ, Sibylle Koczian wrote:
> Am 12.06.2013 22:00, schrieb Νικόλαος Κούρας:
>> On 12/6/2013 10:48 μμ, Sibylle Koczian wrote:
>>>> if '=' not in ( name and month and year ):
>>>> i understand: if '=' not in name AND '=' not in month AND '=' not in
>>>> year
>>>>
>>> Wrong. The "'=' not in (...)" first evaluates the expression in
>>> parentheses, that's what parentheses are for. And then it looks for '='
>>> in the result. And that result is just one of the three values, MRAB
>>> told you which one.
>>
>> okey first the expression eval:
>>
>> ( name and month and year ) = ( name=True and month=True and year=True )
>>
> No. Read MRABs post, he explains it. Or work through the tutorial. This
> would be right in another language, but not in Python.
>
> If this expression would really evaluate to True or False, you
> definitely couldn't search for any character in the result.
>
> As it is, it evaluates to a string or to None, but searching for '=' in
> that string doesn't give the result you think it does.

(name and month and year) is a Boolean expression, correct?

It will return True if all three are True and False otherwise. I cannot 
use it the way i desire regardless of how logical i think it looks.

Basically its just like i'am saying:


if "-" in True:
or
if "-" in False:

Obviously when i write it this way you can see it makes no sense.

======================
But (name or month or year) is also a Boolean expression.

It will return the first of the three depending which value comes first 
as truthy.
it will return False if none of the three are False.

So how am i going to write it that?

if '-' not in name and '-' not in month and '-' not in year:  ??????





More information about the Python-list mailing list