On Wed, Mar 16, 2011 at 12:22 AM, Donald Bedsole <drbeds...@gmail.com>wrote:

>
> not (False and True)
>
> Python evaluates it as "True"
>
> Is it because:
> 1)You evaluate what's in the parentheses first.  A thing can not be
> false and true at the same time, so the answer is false.
>

Yes, the expression in the parenthesis is evaluated first.  However it's not
just one thing being evaluated.

'and' evaluates one argument at a time and returns immediately if the
argument is False.

In this case there are 2 distinct 'things'.  False and True.  False,
obviously, evaluates to False, which causes 'and' to stop and return False.
This reduces the expression to...

not False


> 2)However, the "not" outside the parentheses flips the meaning of what
> is inside the parentheses, so false becomes "True." ?
>

Correct, the expression "not False" evaluates to True.

-- 
Jack Trades
Pointless Programming Blog <http://pointlessprogramming.wordpress.com>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to