On 15/6/2013 8:27 πμ, Larry Hudson wrote:
On 06/14/2013 09:56 AM, Nick the Gr33k wrote:
On 14/6/2013 7:31 μμ, Steven D'Aprano wrote:
On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k wrote:



Returning True is the same thing as returning a variable's truthy value?

NO!  'True' and 'False' are the two values of the boolean type.  The
'and' and 'or' logical operators do NOT return a boolean type of True or
False.

Indeed.

>>> print( name and month and year )
hijk
>>> print( bool( name and month and year ) )
True

>>> print( name or month or year )
abcd
print( bool( name or month or year ) )
True

Also they do NOT return "a variable's truthy value", they return the
variable itself.

No, as seen from my above examples, what is returned after the expr eval are the actual variables' values, which in turn are truthy, *not* the variable itself.

Now, that returned variable can then be interpreted as
a boolean value for other operations in the same way that (virtually)
all data types can be interpreted as a boolean.  Let me emphasize...
they are INTERPRETED as having a boolean VALUE, but they are NOT a
boolean TYPE.

Yes the returned value of 'hijk' is being interpreted as bool('hijk'), which boils down as truthy.



--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to