Eval of expr with 'or' and 'and' within

Nick the Gr33k support at superhost.gr
Sat Jun 15 09:28:16 EDT 2013


On 15/6/2013 12:48 μμ, Lele Gaifax wrote:
>> but those 2 gives the same results back
>>
>> "k" in (name+month+year) == "k" in (name and month and year)
>> True
>>
>> so both seem to work as expected.
> That happens only by chance: it seems you now understand the evaluation
> of "boolean" expressions in Python, so the following should be clear to
> you:

yes indeed!

if we had questioned python for: "k" in (name and year and month)

that would have returned the argument month back which is "efgh" and 
then the if would have evaled to false since 'k' isn't part of the latter.

"k" in (name and month and year) != "k" in (name and year and month)

As wee see, the order of the arguments in an expression matters.

-- 
What is now proved was at first only imagined!



More information about the Python-list mailing list