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

rusi rustompmody at gmail.com
Fri Jun 14 10:05:27 EDT 2013


On Jun 14, 6:48 pm, Zero Piraeus <sche... at gmail.com> wrote:
> :
>
> On 14 June 2013 09:07, Nick the Gr33k <supp... 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.

You get my prize 'Zero' for best answer!

[You've also given me a nice example for my next python class -- I
usually spend time showing how to play in the interpreter.  And the
examples I usually give are numeric/string/list based. Short-circuit
evaluation is good to show. So thanks]

Incidentally, you have also proved right Nicolas' claim that this is
helpful to all :-)  All that is needed is that other charitable-to-
Nick souls on this list should exercise some restraint and provide the
answers that they *know* he *needs* rather than what he *claims* to
*want*.



More information about the Python-list mailing list