conditional expression sought
Sidharth Kuruvila
sidharthk at hotmail.com
Thu Jan 29 19:18:27 CET 2004
since True and False
can also evaluate as 1 and 0
you can use the binary operators
| and &
for or and and respectively
>>> class F:
... a = 5
... def b(self):
... self.a = 4
... return True
... def a(self):
... self.a = 1
... return False
...
>>> g = F()
>>> g.a() & g.b()
False
>>> g.a
4
"Elaine Jackson" <elainejackson7355 at home.com> wrote in message
news:pRbSb.330334$ts4.37644 at pd7tw3no...
> If bool(B_i)==True for 1<=i<=n and j is the smallest i with
bool(A_j)==True,
> then the evaluation of (A_1 and B_1) or ... or (A_n and B_n) returns B_j
without
> evaluating any other B_i. This is such a useful mode of expression that I
would
> like to be able to use something similar even when there is an i with
> bool(B_i)==False. The only thing I can think of by myself is ( (A_1 and
[B_1])
> or ... or (A_n and [B_n]) )[0], and I can't be satisfied with that for
obvious
> reasons. Does anybody know a good way to express this? Any help will be
mucho
> appreciado.
>
> Peace
>
>
More information about the Python-list
mailing list