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

Nick the Gr33k support at superhost.gr
Fri Jun 14 10:08:22 EDT 2013


On 14/6/2013 4:48 μμ, Zero Piraeus wrote:
> :
>
> 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.
>
(a or b or c)

is like saying True or True or True.
the first of these 3 variables that hasn;t as value an emptry string, 
which means they contain a truthy value, that variable's value will be 
returned

For 'and' operator, i do not understand it at all.

-- 
What is now proved was at first only imagined!



More information about the Python-list mailing list