Re: [False,True] and [True,True] -- [True, True]?????
In message pan.2009.04.23.02.26...@remove.this.cybersource.com.au, Steven D'Aprano wrote: On Thu, 23 Apr 2009 13:40:47 +1200, Lawrence D'Oliveiro wrote: In message 25f4735b-52a2-4d53-9097- e623655ca...@k19g2000prh.googlegroups.com, bdb112 wrote: Is there any obvious reason why [False,True] and [True,True] gives [True, True] http://groups.google.co.nz/group/comp.lang.python/msg/396c69e9498d9ad4 Any programming feature is subject to errors from people who try to guess what it does instead of reading the Fine Manual, and Python has no obligation to make every language feature match the random preconceptions of every user. Or even some subset of users. http://groups.google.co.nz/group/comp.lang.python/msg/b12e7b7cbcc82eb0 -- http://mail.python.org/mailman/listinfo/python-list
Re: [False,True] and [True,True] -- [True, True]?????
In message 25f4735b-52a2-4d53-9097- e623655ca...@k19g2000prh.googlegroups.com, bdb112 wrote: Is there any obvious reason why [False,True] and [True,True] gives [True, True] This kind of confusion is why conditional constructs should not accept any values other than True and False http://groups.google.co.nz/group/comp.lang.python/msg/396c69e9498d9ad4. -- http://mail.python.org/mailman/listinfo/python-list
Re: [False,True] and [True,True] -- [True, True]?????
On Thu, 23 Apr 2009 13:40:47 +1200, Lawrence D'Oliveiro wrote: In message 25f4735b-52a2-4d53-9097- e623655ca...@k19g2000prh.googlegroups.com, bdb112 wrote: Is there any obvious reason why [False,True] and [True,True] gives [True, True] This kind of confusion is why conditional constructs should not accept any values other than True and False You've already said this, more than a week ago, in the thread titled Why does Python show the whole array?. It wasn't correct then, and it isn't correct now. Any programming feature is subject to errors from people who try to guess what it does instead of reading the Fine Manual, and Python has no obligation to make every language feature match the random preconceptions of every user. Or even some subset of users. If people guess wrongly what an operator does, then let them learn what it actually *does* do instead of crippling the operator's functionality. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: [False,True] and [True,True] -- [True, True]?????
On Mon, Apr 20, 2009 at 9:03 AM, bdb112 boyd.blackw...@gmail.com wrote: Is there any obvious reason why [False,True] and [True,True] gives [True, True] Well, whether the reason is obvious, I do not know, but the way and seems to be implemented is: X and Y = * X if the boolean value of X is false * Y if the boolean value of X is true In this case, bool([False,True]) = true, so the second element is taken. -- André Engels, andreeng...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [False,True] and [True,True] -- [True, True]?????
En Mon, 20 Apr 2009 04:03:28 -0300, bdb112 boyd.blackw...@gmail.com escribió: Is there any obvious reason why [False,True] and [True,True] gives [True, True] Yes: short-circuit evaluation. [False,True] and [True,True] is *not* an element-by-element operation, it's a simple expression involving two objects (two lists). 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 -- http://mail.python.org/mailman/listinfo/python-list