A certainl part of an if() structure never gets executed.
Nick the Gr33k
support at superhost.gr
Fri Jun 14 05:44:59 EDT 2013
On 14/6/2013 12:21 μμ, Jussi Piitulainen wrote:
> Nick the Gr33k writes:
>
>> On 14/6/2013 11:28 πμ, Jussi Piitulainen wrote:
>>
>>>>>> 'Parker' and 'May' and '2001'
>>> '2001'
>>
>> But why?
>>
>> that expression should return True since all stings are not empty.
>
> It returns a value that counts as true in a conditional statement or
> expression:
When a look at ('Parker' and 'May' and '2001') i can't help it but
interpret it as:
Return True if 'Parker' is not an empty string AND 'May' is not an
empty string AND'2001' is not an empty string.
Why on eart doesn't work this way?
I can understand that the value it results to '2000' is a truthy value,
although i was expecting it to result in True if all parts of
expressions are true.
i just don't understand why it returns back the last value instead.
> Zeroes and empty things tend to count as false in Python, other values
> as true. The values are tested as is, not coerced to a boolean first,
> so the value that decides the value of the whole expression is the
> value of the whole expression.
>
>>>> '' and whatever
> ''
Why does it return th first object back
isn't it like saying False and True and resulting in False?
Please put it in else word how Python unerstand that.
>>>> False and whatever
> False
Same here? The 2nd part of the expression never is been calculated
because the 1st is False?
>>>> 0 and whatever
> 0
Same here? The 2nd part of the expression never is been calculated
because the 1st is False?
>>>> 1 and whatever
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> NameError: name 'whatever' is not defined
>
--
What is now proved was at first only imagined!
More information about the Python-list
mailing list