On 15/6/2013 12:48 μμ, Lele Gaifax wrote:
Nick the Gr33k <supp...@superhost.gr> writes:

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:

"k" in ("there" + "is" + "a" + "k" + "character" + "somewhere")
True

ALL strings in the parenthesis are being concatenated to a BIG string, like ('k' in BIG_string) which returns the Boolean value of True since 'k' is contained within it.

"k" in ("there" and "is" and "a" and "k" and "character" and "somewhere")
False

first the expression of the parenthesis evaluation.

The argument being returned from ("there" and "is" and "a" and "k" and "character" and "somewhere") expresssion, is the one that is responsible for the determination of the expression's evaluation.
That would be the last argument, string "somewhere" because:

1. All previous strings before the last one were found truthies, so it was turn of the last one to be evaled too.

2. Since "somewhere" is a truthy of course for being a non-empty string then ALL arguments of the expression are found TRUE which results for the expression to stand TRUE.

3. What determined the expression to stand TRUE was the evaluation of the last argument "somewhere", so the latter was the key factor for that to happen, hence its being returned back as a result(thats how Python works)

4. so it's like checking if ('k' in "somewhere") which return the Boolean value of False since the aforementioned char isn't contained in the aforementioned string.

--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to