What is the best way to turn a list into a bool value? I am looking for something like:
return eval_bool(my_list)
I have a custom container in which I implement the __nonzero__ method, which should work as follows:
if self.my_list: return True return False
But is it enough pythons? :) In any case, I wonder how Python interprets the value of the list in the if , because this code works differently:
return my_list == True
J.
source share