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
>
> --
> Thanks,
>
>   
The builtin "reduce" does that kind of thing for any function you wish
to apply across the list.    So then its only a matter of giving it a
function that "and"s two arguments:

Either:
    reduce(lambda a,b: a and b,   logFlags)
or
   def and2(a,b):
       return a and b

  reduce(and2, logFlags)

Gary Herron


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

Reply via email to