[Tutor] "x and y" means "if x is false, then x, else y"??

Stefan Behnel stefan_ml at behnel.de
Mon Jul 5 13:09:34 CEST 2010

Richard D. Moores, 05.07.2010 11:37:
> I keep getting hung up over the meaning of "the return
> value" of an expression. I am of course familiar with values returned
> by a function, but don't quite grasp what the return value of, say,
> the y of "x and y" might mean.

Think of a different expression, like "1+1". Here, the return value (or 
maybe a better wording would be the result value) is 2.

> Also, you distinguish between a return value of True and and the value
> of y being such (say 5, and not 0) that it makes y true (but not
> True). So another  thing I need to know is the difference between True
> and true.  Also between False and false. And why the difference is
> important.

"True" is the value "True" in Python, which is a singleton. You can test 
for it by using

     x is True

However, other values can have a true values as well, without being True, e.g.

     if 1: print("TRUE!!!")

will actuall print the string, as the value 1 is considered true when 
turned into a boolean result.


More information about the Tutor mailing list