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

Zero Piraeus schesis at gmail.com
Fri Jun 14 09:48:09 EDT 2013


:

On 14 June 2013 09:07, Nick the Gr33k <support at superhost.gr> wrote:
>
> Thanks for explaining this but i cannot follow its logic at all.
> My mind is stuck trying to interpret it as an English sentence:
>
> if ('Parker' and 'May' and '2001')
>
> if ('Parker' or 'May' or '2001')
>
> i just don't get it and i feel silly about it.

You've been advised many times to experiment in the Python
interpreter. I may be mistaken, but I don't recall seeing any evidence
at all that you've ever done so.

Try the following in a Python interpreter:

>>> "vic" and "bob"
>>> "bob" and "vic"
>>> "vic" or "bob"
>>> "bob" or "vic"
>>> "vic" and ""
>>> "" and "bob"
>>> "bob" or ""
>>> "" or "vic"

Carefully study the results you get. This is simple, basic stuff;
don't come back here asking for explanations of it. If you get stuck,
*carefully* read this article:

  http://en.wikipedia.org/wiki/Short-circuit_evaluation

Repeat the steps above until you do understand. If all else fails,
google "short circuit logic" or "short circuit evaluation python" or
similar search terms, until you find a resource which you do follow.

 -[]z.



More information about the Python-list mailing list