Stephen Hansen wrote:
Look closer: the OP wanted len(Result) > 1 not len(Result) > 0. For that, you need two checks, for example, as for example:On 6/30/10 11:39 AM, Stef Mientki wrote:hello,I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result ) > 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result ) > 1 ) :Just do: if Result:You don't have to do a length check > 1; because if Result has a length of 0, it'll be false too. So the above check will catch both None, and empty sequences.<snip>
if Result and (len(Result)>1):
.
DaveA
--
http://mail.python.org/mailman/listinfo/python-list
