[Python-ideas] Break the dominance of boolean values in boolean context

MRAB python at mrabarnett.plus.com
Wed Sep 14 04:39:47 CEST 2011

On 14/09/2011 01:59, Ned Batchelder wrote:
> On 9/12/2011 4:20 PM, Lukas Lueg wrote:
>> Summing all up, I really think that we should break the dominance of
>> bool() and take a look at how we can implement boolean contexts
>> without relying on boolean values all the time.
> I was surprised to find that any() returns True or False, regardless of
> the values it encounters. Conceptually, these two are the same (where S
> is a sequence S0, S1, S2, ..., Sn):
> any(S)
> S0 or S1 or S2 or ... or Sn
> They are equivalent except that if Sx is the first true-ish value, the
> first will return True while the second returns Sx. Why shouldn't any()
> also return Sx?
If none are true-ish, should it return the final (false-ish) value?

What should any([]) return?

More information about the Python-ideas mailing list