John Henry wrote: > Hi list, > > Is there a more elagant way of doing this? > > # logflags is an array of logicals > test=True > for x in logflags: > test = test and x > print test
There's reduce, but it's not as explicit, and see F's post RE efficiency: >>> x = [True, True, True] >>> y = [True, False, True] >>> print reduce(lambda a, b: a and b, x) True >>> print reduce(lambda a, b: a and b, y) False >>> -- http://mail.python.org/mailman/listinfo/python-list