On 14/6/2013 11:03 πμ, Nick the Gr33k wrote:
On 14/6/2013 4:14 πμ, Steven D'Aprano wrote:
On Thu, 13 Jun 2013 17:26:18 +0300, Νικόλαος Κούρας wrote:

i just want 4 cases to examine so correct execute to be run:

i'm reading and reading and reading this all over:

if '-' not in ( name and month and year ):

and i cant comprehend it.

Don't just read it. Open the interactive interpreter and test it.

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

print(name and month and year)

If you run that, you will see what the result of
(name and month and year) is. Now, ask yourself:

"k" in (name and month and year)

True or false? Check your answer:

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


 >>> 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.

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

No clue. since the expression in parenthesis returns 'abcd' how can 'k'
contained within 'abcd' ?

 >>> print(name and month and year)
ijkl

Seems here is returning the last string out of 3 strings, but have no
clue why Python doing this.

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

yes, since expression returns 'ijkl', then the in operator can detect
the 'k' character within the returned string.


Someone want to explain this?

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

Reply via email to