John Henry wrote:
> 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
Py2.5:
test = all( logflags )
Py2.4 (although somewhat ugly):
try:
test = itertools.ifilterfalse( logflags ).next()
except StopIteration:
test = True
otherwise: your above code will do just fine. Note that you can shortcut,
though, if any of the flags evaluates to False:
test = True
for x in logflags:
if not x:
test = False
break
Stefan
--
http://mail.python.org/mailman/listinfo/python-list