and [True,True] --> [True, True]?????

bdb112 boyd.blackwell at gmail.com
Mon Apr 20 04:16:04 EDT 2009


THanks Gabriel,
Now I know about the zip function.

Your explanation of Boolean ops on lists was clear.
It leads to some intriguing results:

bool([False])
--> True

I wonder if python 3 changes any of this?

> A and B means: check the boolean value of A; if it's false, return A.  
> Else, return B.
> A non-empty list has a boolean value of true, so the second list is  
> returned.
>
> If you want an element-wise operation:
> A = [False,True]
> B = [True,True]
> result = [a and b for a,b in zip(A,B)]
> --
> Gabriel Genellina




More information about the Python-list mailing list