Re: Truthiness

2014-10-23 Thread Steven D'Aprano
Ian Kelly wrote: > No, 3 is merely true, not True. True is just the name of a particular > singleton object that is also true. Sometimes I distinguish between "true" and "True", where True is the canonical boolean true object, but I prefer to refer to "true-like", "true-ish", or "truthy" objects

Re: Truthiness

2014-10-23 Thread Denis McMahon
gs and containers (including strings, tuples, lists, dictionaries, > sets and frozensets). All other values are interpreted as true." Yep, and I expect this to bite S4H shortly, when he can't understand why the following are not all of the same truthiness: 0 (falsey - numeric 0) [] (

Re: Truthiness

2014-10-23 Thread random832
On Thu, Oct 23, 2014, at 10:56, Simon Kennedy wrote: > Thanks everyone. That's a thorough enough explanation for me. You should know, though, that numeric values equal to 1 (and 0 for False) _are_ == True. This works for dictionary keys, array indexes, etc. The bool type is actually a subclass of

Re: Truthiness

2014-10-23 Thread Wolfgang Maier
On 10/23/2014 04:47 PM, Alain Ketterlin wrote: Simon Kennedy writes: Just out of academic interest, is there somewhere in the Python docs where the following is explained? 3 == True False if 3: print("It's Twue") It's Twue i.e. in the if statement 3 is True but not in t

Re: Truthiness

2014-10-23 Thread Simon Kennedy
Thanks everyone. That's a thorough enough explanation for me. -- https://mail.python.org/mailman/listinfo/python-list

Re: Truthiness

2014-10-23 Thread Skip Montanaro
On Thu, Oct 23, 2014 at 9:30 AM, Simon Kennedy wrote: > Just out of academic interest, is there somewhere in the Python docs where > the following is explained? Yes: https://docs.python.org/3/library/stdtypes.html#truth-value-testing https://docs.python.org/2.7/library/stdtypes.html#truth-valu

Re: Truthiness

2014-10-23 Thread Alain Ketterlin
Simon Kennedy writes: > Just out of academic interest, is there somewhere in the Python docs where > the following is explained? > 3 == True > False if 3: > print("It's Twue") > > It's Twue > > i.e. in the if statement 3 is True but not in the first https://docs.python.or

Re: Truthiness

2014-10-23 Thread Wolfgang Maier
On 10/23/2014 04:30 PM, Simon Kennedy wrote: Just out of academic interest, is there somewhere in the Python docs where the following is explained? https://docs.python.org/3/library/stdtypes.html#truth-value-testing 3 == True False as opposed to: https://docs.python.org/3/library/stdtyp

Re: Truthiness

2014-10-23 Thread Ian Kelly
On Thu, Oct 23, 2014 at 8:30 AM, Simon Kennedy wrote: > Just out of academic interest, is there somewhere in the Python docs where > the following is explained? https://docs.python.org/3/reference/expressions.html#booleans 3 == True > False if 3: > print("It's Twue") > > It's

Truthiness

2014-10-23 Thread Simon Kennedy
Just out of academic interest, is there somewhere in the Python docs where the following is explained? >>> 3 == True False >>> if 3: print("It's Twue") It's Twue i.e. in the if statement 3 is True but not in the first -- https://mail.python.org/mailman/listinfo/python-list