On 14/6/2013 5:49 μμ, Grant Edwards wrote:
On 2013-06-14, Nick the Gr33k <supp...@superhost.gr> wrote:

I started another thread

no kidding.

because the last one was !@#$'ed up by irrelevant replies and was
difficult to jeep track.

name="abcd"
month="efgh"
year="ijkl"

print(name or month or year)
abcd

Can understand that, it takes the first string out of the 3 strings
that has a truthy value.

Yes, it does.  That's the way the language is defined to work.  If you
don't like it, pick a different language.

I can understand OR stops at the first value when it finds it truthy, and doesn't care for the other expr parameters.

And that logical since we say:

(name or month or year)
is like saying:

print whatever of those 3 are True, at least 1 of them, if it doesn't not find any though for some reason it defaults to the last variable of the expression(another mystery for me)

the way i realize it is just that for this boolean evaluation of the expression to result in True if any of the above vars holds a truthy value.


Nice try, moving me to another newsgroup list :)

print("k" in (name and month and year))
True

No clue. since the expression in parenthesis returns 'abcd'

No it doesn't.  Try it:

Python 2.7.3 (default, Mar 20 2013, 14:16:24)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

name="abcd"
month="efgh"
year="ijkl"

"k" in (name and month and year)
True
(name and month and year)
'ijkl'


how can 'k' contained within 'abcd' ?
Um sorry was a  typo.

I mean the expr eval results in the value of var year which is 'ijkl'.

>>>> "k" in (name and month and year)
> True

So yes it does.

My question is why the expr (name and month and year) result in the value of the last variable whic is variable year?

I cannot understand AND.

Isn't it like saying that:
(name and month and year)

all of these variables have to have truthy values so for the boolaean eval of the expr result in True?

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

Reply via email to