returning True, False or None

Raymond Hettinger vze4rx4y at verizon.net
Fri Feb 4 15:46:15 EST 2005


"Steven Bethard"
> For a given list:
> * If all values are None, the function should return None.
> * If at least one value is True, the function should return True.
> * Otherwise, the function should return False.

One more approach, just for grins:

    s = set(lst)
    return True in s or s == set([None]) and None


Raymond Hettinger





More information about the Python-list mailing list