"Janto Dreijer" <[EMAIL PROTECTED]> wrote:
|
| Janto Dreijer wrote:
| > John Henry wrote:
| > > Simon Forman wrote:
| > > > >
| > > > > False not in logflags
| > > > >
| > > >
| > > > Or, if your values aren't already bools
| > > >
| > > > False not in (bool(n) for n in logflags)
| > >
| > > Ve
Janto Dreijer wrote:
> Janto Dreijer wrote:
> > John Henry wrote:
> > > Simon Forman wrote:
> > > > >
> > > > > False not in logflags
> > > > >
> > > >
> > > > Or, if your values aren't already bools
> > > >
> > > > False not in (bool(n) for n in logflags)
> > >
> > > Very intriguing use of "not in
Janto Dreijer wrote:
> John Henry wrote:
> > Simon Forman wrote:
> > > >
> > > > False not in logflags
> > > >
> > >
> > > Or, if your values aren't already bools
> > >
> > > False not in (bool(n) for n in logflags)
> >
> > Very intriguing use of "not in"...
>
> Is there a reason why you didn't wr
John Henry wrote:
> Simon Forman wrote:
> > >
> > > False not in logflags
> > >
> >
> > Or, if your values aren't already bools
> >
> > False not in (bool(n) for n in logflags)
>
> Very intriguing use of "not in"...
Is there a reason why you didn't write
True in (bool(n) for n in logflags)
--
h
Simon Forman wrote:
> >
> > False not in logflags
> >
>
> Or, if your values aren't already bools
>
> False not in (bool(n) for n in logflags)
>
>
>
> Peace,
> ~Simon
Very intriguing use of "not in"...
Thanks,
--
http://mail.python.org/mailman/listinfo/python-list
>
> False not in logflags
>
Or, if your values aren't already bools
False not in (bool(n) for n in logflags)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
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,
So many ways *drool*
How about:
False not in logflags
(Anybody gonna run all these throu
Simon Brunning a écrit :
> On 13 Jul 2006 05:45:21 -0700, John Henry <[EMAIL PROTECTED]> wrote:
>
>>
>> Simon Brunning wrote:
>> >
>> > min(logflags)
>> >
>>
>> !!!
>
>
> Be aware that not only is this an outrageous misuse of min(),
+1 QOTW
Ho, my, I've already proposed another one today :(
--
On 13 Jul 2006 05:45:21 -0700, John Henry <[EMAIL PROTECTED]> wrote:
>
> Simon Brunning wrote:
> >
> > min(logflags)
> >
>
> !!!
Be aware that not only is this an outrageous misuse of min(), it's
also almost certainly much less efficient than /F's suggestion, 'cos
it always iterates through the en
Simon Brunning wrote:
> On 12 Jul 2006 11:14:43 -0700, John Henry <[EMAIL PROTECTED]> 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
>
> min(logflags)
>
!!!
> I feel di
On 12 Jul 2006 11:14:43 -0700, John Henry <[EMAIL PROTECTED]> 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
min(logflags)
I feel dirty now. ;-)
--
Cheers,
Simon B,
[EMAIL PROTECTED]
"John Henry" <[EMAIL PROTECTED]> writes:
> # logflags is an array of logicals
> test=True
> for x in logflags:
>test = test and x
> print test
print (False not in map(bool, logflags))
Possibly more "pure" alternative (untested):
from operator import and_
print reduce(and_, map(bo
John Henry <[EMAIL PROTECTED]> 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
test = sum(bool(x) for x in logflags)==len(logflags)
is yet another possibility (without t
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
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 = [Tr
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()
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
your code checks all members, even if the first one's false. that's not
very elegant. here's a better way to do it:
17 matches
Mail list logo