Brian van den Broek <[EMAIL PROTECTED]> wrote:
   ...
> >>* 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.
   ...
> > for val in (x for x in lst if x is not None):
> >     return val
> > return None
   ...
> These don't do what the OP desired.

Ah, you're right, True should take precedence, point 2 of the specs.


OK, let's take advantage of the fact that None < False < True:

return max(lst)


This fails when lst is empty (the specs presumably imply a None should
be returned then).  More robust:

return max(lst or [None])


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to